From 16065b4f19b77111b7fec343969bcf98635e7e27 Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Sat, 1 Jan 2011 18:18:54 +0000 Subject: Some basic tests for the :foreign_type option on belongs_to, which was previously completely untested. --- activerecord/test/models/sponsor.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'activerecord/test/models/sponsor.rb') diff --git a/activerecord/test/models/sponsor.rb b/activerecord/test/models/sponsor.rb index 50c2c2d76c..7e5a1dc38b 100644 --- a/activerecord/test/models/sponsor.rb +++ b/activerecord/test/models/sponsor.rb @@ -1,4 +1,5 @@ class Sponsor < ActiveRecord::Base belongs_to :sponsor_club, :class_name => "Club", :foreign_key => "club_id" belongs_to :sponsorable, :polymorphic => true -end \ No newline at end of file + belongs_to :thing, :polymorphic => true, :foreign_type => :sponsorable_type, :foreign_key => :sponsorable_id +end -- cgit v1.2.3 From 7d4d7457301faa85aa32b5ae29e13976e828954f Mon Sep 17 00:00:00 2001 From: Ernie Miller Date: Thu, 6 Jan 2011 20:06:29 -0500 Subject: Fix polymorphic belongs_to associationproxy raising errors when loading target. --- activerecord/test/models/sponsor.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'activerecord/test/models/sponsor.rb') diff --git a/activerecord/test/models/sponsor.rb b/activerecord/test/models/sponsor.rb index 7e5a1dc38b..aa4a3638fd 100644 --- a/activerecord/test/models/sponsor.rb +++ b/activerecord/test/models/sponsor.rb @@ -2,4 +2,6 @@ class Sponsor < ActiveRecord::Base belongs_to :sponsor_club, :class_name => "Club", :foreign_key => "club_id" belongs_to :sponsorable, :polymorphic => true belongs_to :thing, :polymorphic => true, :foreign_type => :sponsorable_type, :foreign_key => :sponsorable_id + belongs_to :sponsorable_with_conditions, :polymorphic => true, + :foreign_type => 'sponsorable_type', :foreign_key => 'sponsorable_id', :conditions => {:name => 'Ernie'} end -- cgit v1.2.3