Now
a days Rails 3.2 version is going on. I am going to write some
difference between in Rails 2.x and 3.x.
1. Some command line syntax has been changed in Rails 3.x like as
- rails generate instead of rails script/generate
- rails server instead of ruby server
2. Introduction of bundler (New way to manage your gem dependencies)
3. Gemfile and Gemfile.lock (Where all your gem dependencies
lies, instead of environment.rb)
4. A new .rb file in config/
folder, named as application.rb (Which has everything that
previously environment.rb had)
5. Change in SQL Structure: Model.where(:activated => true)
6. All the mailer script will now be in app/mailers folder, earlier we kept inside app/models.
7. Rails3-UJS support. for links and forms to work as AJAX, instead of writing complex lines of code, we write
:remote => true
8. HTML 5 support.
9. Changes
in the model based validation syntax:
validates :name, :presence => true
validates :name, :presence => true
10. Ability to install windows/ruby/jruby/development/production specific gems to Gemfile.
group :production do
gem 'will_paginate'
end
gem 'will_paginate'
end
11. Rails 3.x has changed routing syntax eg :
- Rails 2.x : map.connect ‘hello_word’, :controller=> ‘posts’, :action => ‘index’
Rails 3.x : match “hello_world” => ‘post#index’
- Rails 2.x: map.resources :users
Rails 3.x: resources :users
- Rails 2.x : map.root :controller => ‘posts’, :action => ‘index’
Rails3.x: root :to => ‘post#index’
No comments:
Post a Comment