diff options
author | George Ogata <george.ogata@gmail.com> | 2009-11-29 00:46:09 -0500 |
---|---|---|
committer | Eloy Duran <eloy.de.enige@gmail.com> | 2009-12-28 15:12:13 +0100 |
commit | 81ca0cf2b074f4b868a84c427ef155607a956119 (patch) | |
tree | 767bccec4edba6ad384c1961de4f6c46a812662b /activerecord/test/models | |
parent | 6c8c85bc1eaf1639ea0df5f356e7105c74d128b2 (diff) | |
download | rails-81ca0cf2b074f4b868a84c427ef155607a956119.tar.gz rails-81ca0cf2b074f4b868a84c427ef155607a956119.tar.bz2 rails-81ca0cf2b074f4b868a84c427ef155607a956119.zip |
Add inverse polymorphic association support. [#3520 state:resolved]
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/face.rb | 1 | ||||
-rw-r--r-- | activerecord/test/models/interest.rb | 1 | ||||
-rw-r--r-- | activerecord/test/models/man.rb | 2 |
3 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/test/models/face.rb b/activerecord/test/models/face.rb index 1540dbf741..3e2bdc0307 100644 --- a/activerecord/test/models/face.rb +++ b/activerecord/test/models/face.rb @@ -1,5 +1,6 @@ class Face < ActiveRecord::Base belongs_to :man, :inverse_of => :face + belongs_to :polymorphic_man, :polymorphic => true, :inverse_of => :polymorphic_face # This is a "broken" inverse_of for the purposes of testing belongs_to :horrible_man, :class_name => 'Man', :inverse_of => :horrible_face end diff --git a/activerecord/test/models/interest.rb b/activerecord/test/models/interest.rb index d8291d00cc..d5d9226204 100644 --- a/activerecord/test/models/interest.rb +++ b/activerecord/test/models/interest.rb @@ -1,4 +1,5 @@ class Interest < ActiveRecord::Base belongs_to :man, :inverse_of => :interests + belongs_to :polymorphic_man, :polymorphic => true, :inverse_of => :polymorphic_interests belongs_to :zine, :inverse_of => :interests end diff --git a/activerecord/test/models/man.rb b/activerecord/test/models/man.rb index f40bc9d0fc..4bff92dc98 100644 --- a/activerecord/test/models/man.rb +++ b/activerecord/test/models/man.rb @@ -1,6 +1,8 @@ class Man < ActiveRecord::Base has_one :face, :inverse_of => :man + has_one :polymorphic_face, :class_name => 'Face', :as => :polymorphic_man, :inverse_of => :polymorphic_man has_many :interests, :inverse_of => :man + has_many :polymorphic_interests, :class_name => 'Interest', :as => :polymorphic_man, :inverse_of => :polymorphic_man # These are "broken" inverse_of associations for the purposes of testing has_one :dirty_face, :class_name => 'Face', :inverse_of => :dirty_man has_many :secret_interests, :class_name => 'Interest', :inverse_of => :secret_man |