diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-07-27 12:36:00 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-07-27 12:36:00 +0100 |
commit | 24f0a872e660647fe1abf187748660a77da3fe0a (patch) | |
tree | 90d73dab29167e425d260f4f9335f103aec35482 /activerecord/lib/active_record/associations.rb | |
parent | 46b8261830d25d444a95e496e5f8becc27df76cc (diff) | |
download | rails-24f0a872e660647fe1abf187748660a77da3fe0a.tar.gz rails-24f0a872e660647fe1abf187748660a77da3fe0a.tar.bz2 rails-24f0a872e660647fe1abf187748660a77da3fe0a.zip |
Add a proxy_association method to association proxies, which can be called by association extensions to access information about the association. This replaces proxy_owner etc with proxy_association.owner.
Diffstat (limited to 'activerecord/lib/active_record/associations.rb')
-rw-r--r-- | activerecord/lib/active_record/associations.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 029d7a9b15..2605a54cb6 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -460,6 +460,12 @@ module ActiveRecord # * <tt>record.association(:items).target</tt> - Returns the associated object for +belongs_to+ and +has_one+, or # the collection of associated objects for +has_many+ and +has_and_belongs_to_many+. # + # However, inside the actual extension code, you will not have access to the <tt>record</tt> as + # above. In this case, you can access <tt>proxy_association</tt>. For example, + # <tt>record.association(:items)</tt> and <tt>record.items.proxy_association</tt> will return + # the same object, allowing you to make calls like <tt>proxy_association.owner</tt> inside + # association extensions. + # # === Association Join Models # # Has Many associations can be configured with the <tt>:through</tt> option to use an |