aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-05-11 12:01:08 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2009-05-11 12:20:54 -0700
commitddbeb15a5e7e0c3c5f316ccf65b557bc5311a6c4 (patch)
tree96af79cc6a1fbf6be739102bd2afeec1f2df7ef6 /activerecord
parente1854e0b199fba352ddcaa58a3af168e8cc70e3a (diff)
downloadrails-ddbeb15a5e7e0c3c5f316ccf65b557bc5311a6c4.tar.gz
rails-ddbeb15a5e7e0c3c5f316ccf65b557bc5311a6c4.tar.bz2
rails-ddbeb15a5e7e0c3c5f316ccf65b557bc5311a6c4.zip
Revert "Fixed bug with polymorphic has_one :as pointing to an STI record"
[#2594 state:open] This reverts commit 99c103be1165da9c8299bc0977188ecf167e06a5.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/associations/has_one_association.rb2
-rw-r--r--activerecord/test/cases/associations/has_one_associations_test.rb9
-rw-r--r--activerecord/test/fixtures/organizations.yml4
-rw-r--r--activerecord/test/fixtures/sponsors.yml4
-rw-r--r--activerecord/test/models/organization.rb4
-rw-r--r--activerecord/test/schema/schema.rb3
6 files changed, 5 insertions, 21 deletions
diff --git a/activerecord/lib/active_record/associations/has_one_association.rb b/activerecord/lib/active_record/associations/has_one_association.rb
index 4908005d2e..b72b84343b 100644
--- a/activerecord/lib/active_record/associations/has_one_association.rb
+++ b/activerecord/lib/active_record/associations/has_one_association.rb
@@ -90,7 +90,7 @@ module ActiveRecord
when @reflection.options[:as]
@finder_sql =
"#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_id = #{owner_quoted_id} AND " +
- "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_type = #{@owner.class.quote_value(@owner.class.name.to_s)}"
+ "#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_type = #{@owner.class.quote_value(@owner.class.base_class.name.to_s)}"
else
@finder_sql = "#{@reflection.quoted_table_name}.#{@reflection.primary_key_name} = #{owner_quoted_id}"
end
diff --git a/activerecord/test/cases/associations/has_one_associations_test.rb b/activerecord/test/cases/associations/has_one_associations_test.rb
index 3984945f9f..1ddb3f49bf 100644
--- a/activerecord/test/cases/associations/has_one_associations_test.rb
+++ b/activerecord/test/cases/associations/has_one_associations_test.rb
@@ -2,11 +2,9 @@ require "cases/helper"
require 'models/developer'
require 'models/project'
require 'models/company'
-require 'models/sponsor'
-require 'models/organization'
class HasOneAssociationsTest < ActiveRecord::TestCase
- fixtures :accounts, :companies, :developers, :projects, :developers_projects, :organizations, :sponsors
+ fixtures :accounts, :companies, :developers, :projects, :developers_projects
def setup
Account.destroyed_account_ids.clear
@@ -308,9 +306,4 @@ class HasOneAssociationsTest < ActiveRecord::TestCase
Firm.find(@firm.id, :include => :account).save!
end
end
-
- def test_polymorphic_sti
- assert_equal organizations(:sponsorable), sponsors(:org_sponsor).sponsorable
- assert_equal sponsors(:org_sponsor), organizations(:sponsorable).sponsor
- end
end
diff --git a/activerecord/test/fixtures/organizations.yml b/activerecord/test/fixtures/organizations.yml
index 05d620fbc6..25295bff87 100644
--- a/activerecord/test/fixtures/organizations.yml
+++ b/activerecord/test/fixtures/organizations.yml
@@ -2,6 +2,4 @@ nsa:
name: No Such Agency
discordians:
name: Discordians
-sponsorable:
- name: We Need Money
- type: SponsorableOrganization
+
diff --git a/activerecord/test/fixtures/sponsors.yml b/activerecord/test/fixtures/sponsors.yml
index 97a7784047..42df8957d1 100644
--- a/activerecord/test/fixtures/sponsors.yml
+++ b/activerecord/test/fixtures/sponsors.yml
@@ -6,6 +6,4 @@ boring_club_sponsor_for_groucho:
sponsorable: some_other_guy (Member)
crazy_club_sponsor_for_groucho:
sponsor_club: crazy_club
- sponsorable: some_other_guy (Member)
-org_sponsor:
- sponsorable: sponsorable (SponsorableOrganization) \ No newline at end of file
+ sponsorable: some_other_guy (Member) \ No newline at end of file
diff --git a/activerecord/test/models/organization.rb b/activerecord/test/models/organization.rb
index 5d1308354d..d79d5037c8 100644
--- a/activerecord/test/models/organization.rb
+++ b/activerecord/test/models/organization.rb
@@ -1,8 +1,4 @@
class Organization < ActiveRecord::Base
has_many :member_details
has_many :members, :through => :member_details
-end
-
-class SponsorableOrganization < Organization
- has_one :sponsor, :as => :sponsorable
end \ No newline at end of file
diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb
index 6fb918c60e..a776cd974b 100644
--- a/activerecord/test/schema/schema.rb
+++ b/activerecord/test/schema/schema.rb
@@ -284,7 +284,6 @@ ActiveRecord::Schema.define do
create_table :organizations, :force => true do |t|
t.string :name
- t.string :type
end
create_table :owners, :primary_key => :owner_id ,:force => true do |t|
@@ -390,7 +389,7 @@ ActiveRecord::Schema.define do
create_table :sponsors, :force => true do |t|
t.integer :club_id
t.integer :sponsorable_id
- t.string :sponsorable_type
+ t.string :sponsorable_type
end
create_table :subscribers, :force => true, :id => false do |t|