Skip to content

Commit

Permalink
Merge pull request rails#5720 from kennyj/should_use_klass_method
Browse files Browse the repository at this point in the history
Get a properly aliased_table_name, when we use a polymorphic association.
  • Loading branch information
jonleighton committed Apr 11, 2012
2 parents ddefdd7 + bfb9b71 commit 19ecde0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/associations/association.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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+.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 19ecde0

Please sign in to comment.