3 ms·
From what I've seen most of the basic knowledge involved in creating a Rails 2.X app translates well for Rails 3. The basic application structure and the way of
by aarongough 16y ago
From what I've seen most of the basic knowledge involved in creating a Rails 2.X app translates well for Rails 3. The basic application structure and the way of thinking about the layout of the application remains largely unchanged.
Some highlight differences difference being:
# ActiveRecord query syntax
2.X: User.all(:conditions => {:name => "aaron"}, :limit => 1)
3.X: User.where(:name => "aaron").limit(1)
# ActionMailer API now closely matches the ActionController API
2.X:
class Notifier
def user_notification(user)
recipients user.email
subject "test subject"
from "system@test.com"
body :user => user
end
end
3.X:
class Notifier
default :from => "system@test.com"
def user_notification(user)
@user = user
end
end
In Rails 3 Gem dependencies are managed using Bundler, which means that you have to explicitly declare all of the gems your application uses, even fundamental things like Rails and Rack. Calls to config.gem need to be removed, and added to a Gemfile instead.
There are quite a few more API changes than what I have listed here, routes in particular will change greatly for complex applications. The full details are here: http://guides.rails.info/3_0_release_notes.html http://guides.rails.info/3_0_release_notes.html