Rails 4 Highlights
StrongParameters: replaces attr_accessor, attr_protected, moves param filtering concern to the controller rather than the model. Moving param filtering concern to the controller allows you to more easily modify user attribute change-ability in controllers (e.g. customer-facing vs admin).
ActiveSupport::Queue: Add queueing support to Rails, like:
# Add to queue Rails.queue.push UserRegistrationMailerJob(@user.id) # Control queue configuration (asynchronous, synchronous or resque, e.g. config.queue = [:asynchronous, :synchronous, :resque]
Cache Digests: Rails 4.0 introduces cache key generation based on an item and its dependencies, so nested cache elements properly expire when an item is updated.
Improvements to ActiveRecord::Relation
- Relation.all: returns ActiveRecord::relation object.
User.all => User.to_a
- Relation.none: Returns
ActiveRecord::NullRelation
, still chain. - Relation.___!: mutates current relation, e.g.
@users.where!, @users.include!
- Relation.all: returns ActiveRecord::relation object.
Deprecations
- AR::Base.scoped
- Dynamic Finder Methods: e.g. find_all_by_ *
- Hash-based Finders: e.g. User.find(:first)
- Eager Evaluated Scope: scope will require a lambda
- ActiveRecord::SessionStore
- ActiveResource
- Rails::Plugin
PATCH verb support: Support of HTTP PATCH
method (_method equals "patch")
, which will map to your update action is introduced in Rails 4.0.Routing Concern: Rails 4.0 introduces some methods to help clean up your duplicate routes.
Deprecation Policy: Many of the above deprecations will still work in Rails 4.0 and included as gem dependencies, but will be removed in the jump to Rails 4.1. This means that the upgrade to Rails 4.1 may be more painful than the upgrade to Rails 4.0.
No comments:
Post a Comment