diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-05-05 10:14:28 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-05-05 10:14:28 -0300 |
commit | a83a1ccebaaae5e05741ebd5d9db408c450df098 (patch) | |
tree | 79dc5924ce11481674180e1d216ec6551e634011 /activerecord/lib/active_record/associations/association_proxy.rb | |
parent | d19d4d2f20d87289eaeaa8df807d635ce72f3799 (diff) | |
parent | d4402c5554a0d3202fc22eb38c5c1a8c4b9afd93 (diff) | |
download | rails-a83a1ccebaaae5e05741ebd5d9db408c450df098.tar.gz rails-a83a1ccebaaae5e05741ebd5d9db408c450df098.tar.bz2 rails-a83a1ccebaaae5e05741ebd5d9db408c450df098.zip |
Merge commit 'rails/master'
Diffstat (limited to 'activerecord/lib/active_record/associations/association_proxy.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/association_proxy.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations/association_proxy.rb b/activerecord/lib/active_record/associations/association_proxy.rb index 241b9bfee0..e36b04ea95 100644 --- a/activerecord/lib/active_record/associations/association_proxy.rb +++ b/activerecord/lib/active_record/associations/association_proxy.rb @@ -53,6 +53,7 @@ module ActiveRecord def initialize(owner, reflection) @owner, @reflection = owner, reflection + reflection.check_validity! Array(reflection.options[:extend]).each { |ext| proxy_extend(ext) } reset end @@ -274,6 +275,19 @@ module ActiveRecord def owner_quoted_id @owner.quoted_id end + + def set_inverse_instance(record, instance) + return if record.nil? || !we_can_set_the_inverse_on_this?(record) + inverse_relationship = @reflection.inverse_of + unless inverse_relationship.nil? + record.send(:"set_#{inverse_relationship.name}_target", instance) + end + end + + # Override in subclasses + def we_can_set_the_inverse_on_this?(record) + false + end end end end |