diff options
author | Jon Leighton <j@jonathanleighton.com> | 2012-08-03 10:50:49 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2012-08-03 11:05:31 +0100 |
commit | bf2df6e7ba495ac4d2264e0e2558c366f217ee5d (patch) | |
tree | 775ae427819b2200b0ae3c85619d4f5cc8f8c203 /activerecord/CHANGELOG.md | |
parent | c391919180a19a31a04b9483396d0543a4bed961 (diff) | |
download | rails-bf2df6e7ba495ac4d2264e0e2558c366f217ee5d.tar.gz rails-bf2df6e7ba495ac4d2264e0e2558c366f217ee5d.tar.bz2 rails-bf2df6e7ba495ac4d2264e0e2558c366f217ee5d.zip |
Allow Relation#merge to take a proc.
This was requested by DHH to allow creating of one's own custom
association macros.
For example:
module Commentable
def has_many_comments(extra)
has_many :comments, -> { where(:foo).merge(extra) }
end
end
class Post < ActiveRecord::Base
extend Commentable
has_many_comments -> { where(:bar) }
end
Diffstat (limited to 'activerecord/CHANGELOG.md')
-rw-r--r-- | activerecord/CHANGELOG.md | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index c78e602af7..8356b49bec 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,5 +1,25 @@ ## Rails 4.0.0 (unreleased) ## +* Allow Relation#merge to take a proc. + + This was requested by DHH to allow creating of one's own custom + association macros. + + For example: + + module Commentable + def has_many_comments(extra) + has_many :comments, -> { where(:foo).merge(extra) } + end + end + + class Post < ActiveRecord::Base + extend Commentable + has_many_comments -> { where(:bar) } + end + + *Jon Leighton* + * Add CollectionProxy#scope This can be used to get a Relation from an association. |