Coerce strings in create_join_table.

If you accidentally pass a string and a symbol, this breaks. So
we coerce them both to strings.

Fixes #7715
This commit is contained in:
Steve Klabnik 2012-09-20 15:09:21 +03:00
parent 2068d30091
commit 48a035712e
2 changed files with 8 additions and 1 deletions

View File

@ -8,7 +8,7 @@ module ActiveRecord
end
def join_table_name(table_1, table_2)
[table_1, table_2].sort.join("_").to_sym
[table_1.to_s, table_2.to_s].sort.join("_").to_sym
end
end
end

View File

@ -759,4 +759,11 @@ class CopyMigrationsTest < ActiveRecord::TestCase
ensure
clear
end
def test_create_join_table_with_symbol_and_string
connection.create_join_table :artists, 'musics'
assert_equal %w(artist_id music_id), connection.columns(:artists_musics).map(&:name).sort
end
end