diff options
Diffstat (limited to 'activerecord/CHANGELOG')
-rw-r--r-- | activerecord/CHANGELOG | 47 |
1 files changed, 23 insertions, 24 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 93eb42a52c..a03751a6c1 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,22 +1,30 @@ *Rails 3.1.0 (unreleased)* -* Passing a proc (or other object that responds to #call) to scope is deprecated. If you need your - scope to be lazily evaluated, or takes parameters, please define it as a normal class method - instead. For example, change this: +* AR#new, AR#create and AR#update_attributes all accept a second hash as option that allows you + to specify which role to consider when assigning attributes. This is built on top of ActiveModel's + new mass assignment capabilities: class Post < ActiveRecord::Base - scope :unpublished, lambda { where('published_at > ?', Time.now) } + attr_accessible :title + attr_accessible :title, :published_at, :as => :admin end - To this: + Post.new(params[:post], :as => :admin) - class Post < ActiveRecord::Base - def self.unpublished - where('published_at > ?', Time.now) - end - end + assign_attributes() with similar API was also added and attributes=(params, guard) was deprecated. + + [Josh Kalderimis] - [Jon Leighton] +* default_scope can take a block, lambda, or any other object which responds to `call` for lazy + evaluation: + + default_scope { ... } + default_scope lambda { ... } + default_scope method(:foo) + + This feature was originally implemented by Tim Morgan, but was then removed in favour of + defining a 'default_scope' class method, but has now been added back in by Jon Leighton. + The relevant lighthouse ticket is #1812. * Default scopes are now evaluated at the latest possible moment, to avoid problems where scopes would be created which would implicitly contain the default scope, which would then @@ -29,25 +37,16 @@ [Jon Leighton] -* Deprecated support for passing hashes and relations to 'default_scope'. Please create a class - method for your scope instead. For example, change this: - - class Post < ActiveRecord::Base - default_scope where(:published => true) - end - - To this: +* If you wish to merge default scopes in special ways, it is recommended to define your default + scope as a class method and use the standard techniques for sharing code (inheritance, mixins, + etc.): class Post < ActiveRecord::Base def self.default_scope - where(:published => true) + where(:published => true).where(:hidden => false) end end - Rationale: It will make the implementation simpler because we can simply use inheritance to - handle inheritance scenarios, rather than trying to make up our own rules about what should - happen when you call default_scope multiple times or in subclasses. - [Jon Leighton] * PostgreSQL adapter only supports PostgreSQL version 8.2 and higher. |