Nithin Bekal

Posts About Notes Slides

Rails

Other notes related to Rails:

Rails setup

Rails application servers

Rails metrics

Rails Deployment

Rails Internals

Rails and Databases

Rails API applications

Indexing in Rails

  • Always add index for foreign keys
# Bad
create_table(:tweets) do |t|
  t.string  :text
  t.integer :user_id
end

# OK
create_table(:tweets) do |t|
  t.string  :text
  t.integer :user_id
end
add_index :posts, :user_id

# Better - automatically adds user_id field and creates index
create_table(:tweets) do |t|
  t.string     :text
  t.references :user
end

Authentication from scratch

Contributing to Rails

  • Install Virtualbox - https://www.virtualbox.org/wiki/Downloads
  • Install Vagrant - http://www.vagrantup.com/downloads
  • Clone rails-dev-box - https://github.com/rails/rails-dev-box
  • git clone https://github.com/rails/rails-dev-box.git
cd rails-dev-box
vagrant up

This will take a lot of time the first time. A LOT.

git clone git@github.com:nithinbekal/rails.git

The current directory will be mounted as /vagrant in the vagrant box.

vagrant ssh
cd /vagrant/rails
bundle

Get the latest changes from upstream rails:

git remote add rails git://github.com/rails/rails.git
git fetch rails
git checkout master
git rebase rails/master

git push origin master

bundle exec rake test
  • takes long long time to run