diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-12-10 19:15:07 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-12-10 19:15:07 -0200 |
commit | 81e940c313b6924915ca77a0f3af66332c9f0b1f (patch) | |
tree | 0648b6f0e34b6cc7e440fff03593e090d7cb8cd0 /activerecord/test/models | |
parent | efe80bce9765f7fcc1d09338a212f8ea1c4d7a7a (diff) | |
parent | 075c81feec87b1e5bfec27ed585c4ab613c2d174 (diff) | |
download | rails-81e940c313b6924915ca77a0f3af66332c9f0b1f.tar.gz rails-81e940c313b6924915ca77a0f3af66332c9f0b1f.tar.bz2 rails-81e940c313b6924915ca77a0f3af66332c9f0b1f.zip |
Merge pull request #17970 from ulissesalmeida/foreign-type-has-many-has-one
Add foreign_type option for polymorphic has_one and has_many.
Diffstat (limited to 'activerecord/test/models')
-rw-r--r-- | activerecord/test/models/image.rb | 3 | ||||
-rw-r--r-- | activerecord/test/models/post.rb | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/test/models/image.rb b/activerecord/test/models/image.rb new file mode 100644 index 0000000000..7ae8e4a7f6 --- /dev/null +++ b/activerecord/test/models/image.rb @@ -0,0 +1,3 @@ +class Image < ActiveRecord::Base + belongs_to :imageable, foreign_key: :imageable_identifier, foreign_type: :imageable_class +end diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb index 57e1818e49..56073cc588 100644 --- a/activerecord/test/models/post.rb +++ b/activerecord/test/models/post.rb @@ -128,6 +128,9 @@ class Post < ActiveRecord::Base has_many :taggings_using_author_id, :primary_key => :author_id, :as => :taggable, :class_name => 'Tagging' has_many :tags_using_author_id, :through => :taggings_using_author_id, :source => :tag + has_many :images, :as => :imageable, :foreign_key => :imageable_identifier, :foreign_type => :imageable_class + has_one :main_image, :as => :imageable, :foreign_key => :imageable_identifier, :foreign_type => :imageable_class, :class_name => 'Image' + has_many :standard_categorizations, :class_name => 'Categorization', :foreign_key => :post_id has_many :author_using_custom_pk, :through => :standard_categorizations has_many :authors_using_custom_pk, :through => :standard_categorizations |