reading Rails 3 Release Note (1:Upgrading to 7:Action Pack)
routing 重要。
色々萌える。escaping by default はやっとか!って感じだけど。
sources
- en: http://guides.rails.info/3_0_release_notes.html
- ja: http://blog.bluemoderns.com/articles/2010/02/07/ruby-on-rails-3-1
more infos
- http://guides.rails.info/ updating one by one to reflect the changes in Rails 3
- guides.rails.info: edge
- guides.rubyonrails.org: stable version
Intro
- RESTful declaration router
- AR chainable query lang built on top of relational algebra
- unobtrusive js driver for jQ and more coming
- Bundler
Upgrading to Rails 3
- Application Object
- for supporting running multiple app in the same process
- has specific config
- defined in config/application.rb
- managing gems
- use bundler and Gemfile
- config.gem has gone
- rails_upgrade offers generating Gemfile based on config.gem
- use plugin for update: http://github.com/rails/rails_upgrade
Architectural Change
- six major changes
- 1. Railties
- 2. core components are decoupled
- rails core components are now using the same API that you can use for developing plugins
- any components, including core, are replaceable (like DataMapper or Sequel)
- more info: http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/
- 3. Active Model abstraction
- untied AR from ActionPack
- all ORM need to implement Active Model interface to work with Action Pack
- more: http://yehudakatz.com/2010/01/10/activemodel-make-any-ruby-object-feel-like-activerecord/
- 4. Controller abstraction
- Abstruction Controller, a base super class
- http://yehudakatz.com/2009/06/11/rails-edge-architecture/
- 5. Arel Integration
- 6. Mail Extraction
Internationalization
- i18n behavior can be added to any object
- like a ActiveModel::Translation, ActiveModel::Validations
- errors.messages feedback, and the form
- more: http://blog.plataformatec.com.br/2010/02/rails-3-i18n-changes/
Railties
- each app now has its own namespace
- anything under Rails.root/app is now added to the load path
- you can make app/observers/user_observer.rb
- Rails.config, Rails wide configuration option
- generators
- allow you to override the templates by placing a copy at RAILS_ROOT/lib/templates
- rake
- rake routes CONTROLLER=x show the routes for one controller
- deprecated
Action Pack
Action Controller
- application_controller.rb
- now has protect_from_forgery on by default
- cookie / session
- some settings moved to initializers/*.rb
- cookie_verifier_secret
- session_store
- some settings moved to initializers/*.rb
- cookies.secure allowing you to set encrypted in cookie with cookie.secure[:key] => value
- cookies.permanent, cookie.permanent[:key] => value
- can pass :notice => flash_msg, :alert => flash_msg to the format object call inside a respond_to block. flash[] still works
- more
Action View
- escaping by default
- no longer need to call h(string)
- use raw(string) to unescape
- helpers now output HTML 5 by default
- form label helper now pulls values from i18n
- select label on should now be :en.helpers.select
- no longer need to place '-' sign on ERb
- added as new
- grouped_collection_select helper
- content_for? allowing you to check before rendering
Action Pack / Action Dispatch
- provides a new & cleaner implementation for routing
- Rails router is now rack_mount with DSL on top
- constraints method allowing you to guard routes with constraints
- root method as a short cut for match '/', :to=>path
- map still works but will be removed at 3.1
- more
# former ActionController::Routing::Routes.draw do |map| map.resources :posts end # now AppName::Application.routes do resources :posts end # and scope # below gives you the edit action with /es/projeto/1/cambiar scope 'es' do resources :projects, :path_names => { :edit => ''cambiar' }, :as => 'projeto' end # you can pass optional segments # each parenthesize segment is optional '/:controller(/:action(/:id))(.:format) # routes can be expressed via block controller :home { match '/:action' }