diff options
author | Jon Leighton <j@jonathanleighton.com> | 2012-05-11 17:19:30 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2012-05-11 20:11:04 +0100 |
commit | c86a32d7451c5d901620ac58630460915292f88b (patch) | |
tree | 6a424a15b39d3a5bfee68c41d4665c494ff0e8aa /activerecord/test/cases/associations/inverse_associations_test.rb | |
parent | a8637cf4938d2decd17e702c399ca9c0cf1a6052 (diff) | |
download | rails-c86a32d7451c5d901620ac58630460915292f88b.tar.gz rails-c86a32d7451c5d901620ac58630460915292f88b.tar.bz2 rails-c86a32d7451c5d901620ac58630460915292f88b.zip |
CollectionProxy < Relation
This helps bring the interfaces of CollectionProxy and Relation closer
together, and reduces the delegation backflips we need to perform.
For example, first_or_create is defined thus:
class ActiveRecord::Relation
def first_or_create(...)
first || create(...)
end
end
If CollectionProxy < Relation, then post.comments.first_or_create will
hit the association's #create method which will actually add the new record
to the association, just as post.comments.create would.
With the previous delegation, post.comments.first_or_create expands to
post.comments.scoped.first_or_create, where post.comments.scoped has no
knowledge of the association.
Diffstat (limited to 'activerecord/test/cases/associations/inverse_associations_test.rb')
0 files changed, 0 insertions, 0 deletions