Permalink
Browse files

Get a properly aliased_table_name, when we use a polymorphic associat…

…ion.
  • Loading branch information...
1 parent 0cc6c5f commit bfb9b7165ef4cb18835f65be600778bd8b1d6d11 @kennyj kennyj committed Apr 3, 2012
@@ -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+.
@@ -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

0 comments on commit bfb9b71

Please sign in to comment.