From b1ea27630df0f0639900b321d756091b42ed29f7 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 2 Feb 2008 03:27:31 +0000 Subject: Fix has_many :through a polymorphic has_many. Closes #10529 [Aleksey Kondratenko] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8776 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/test/models/pirate.rb | 4 +++- activerecord/test/models/price_estimate.rb | 3 +++ activerecord/test/models/treasure.rb | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 activerecord/test/models/price_estimate.rb (limited to 'activerecord/test/models') diff --git a/activerecord/test/models/pirate.rb b/activerecord/test/models/pirate.rb index f7193dfbe0..bb4d02c10f 100644 --- a/activerecord/test/models/pirate.rb +++ b/activerecord/test/models/pirate.rb @@ -1,5 +1,7 @@ class Pirate < ActiveRecord::Base belongs_to :parrot has_and_belongs_to_many :parrots - has_many :loots, :as => :looter + has_many :treasures, :as => :looter + + has_many :treasure_estimates, :through => :treasures, :source => :price_estimates end diff --git a/activerecord/test/models/price_estimate.rb b/activerecord/test/models/price_estimate.rb new file mode 100644 index 0000000000..ef3bba36a9 --- /dev/null +++ b/activerecord/test/models/price_estimate.rb @@ -0,0 +1,3 @@ +class PriceEstimate < ActiveRecord::Base + belongs_to :estimate_of, :polymorphic => true +end diff --git a/activerecord/test/models/treasure.rb b/activerecord/test/models/treasure.rb index 7a429e2a2f..97c690c110 100644 --- a/activerecord/test/models/treasure.rb +++ b/activerecord/test/models/treasure.rb @@ -1,4 +1,6 @@ class Treasure < ActiveRecord::Base has_and_belongs_to_many :parrots belongs_to :looter, :polymorphic => true + + has_many :price_estimates, :as => :estimate_of end -- cgit v1.2.3