Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #5720 from kennyj/should_use_klass_method

Get a properly aliased_table_name, when we use a polymorphic association.
  • Loading branch information...
commit 19ecde00ff8a72c0c09685525c9d1eace79e8d75 2 parents ddefdd7 + bfb9b71
@jonleighton jonleighton authored
View
2  activerecord/lib/active_record/associations/association.rb
@@ -39,7 +39,7 @@ def initialize(owner, reflection)
# post.comments.aliased_table_name # => "comments"
#
def aliased_table_name
- reflection.klass.table_name
+ klass.table_name
end
# Resets the \loaded flag to +false+ and sets the \target to +nil+.
View
1  activerecord/test/cases/associations/belongs_to_associations_test.rb
@@ -168,6 +168,7 @@ def test_polymorphic_association_class
sponsor.sponsorable = Member.new :name => "Bert"
assert_equal Member, sponsor.association(:sponsorable).send(:klass)
+ assert_equal "members", sponsor.association(:sponsorable).aliased_table_name
end
def test_with_polymorphic_and_condition
Please sign in to comment.
Something went wrong with that request. Please try again.