Skip to content

Commit 48a0357

Browse files
committed
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 rails#7715
1 parent 2068d30 commit 48a0357

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

activerecord/lib/active_record/migration/join_table.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def find_join_table_name(table_1, table_2, options = {})
88
end
99

1010
def join_table_name(table_1, table_2)
11-
[table_1, table_2].sort.join("_").to_sym
11+
[table_1.to_s, table_2.to_s].sort.join("_").to_sym
1212
end
1313
end
1414
end

activerecord/test/cases/migration_test.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,4 +759,11 @@ def test_copying_migrations_to_empty_directory
759759
ensure
760760
clear
761761
end
762+
763+
def test_create_join_table_with_symbol_and_string
764+
connection.create_join_table :artists, 'musics'
765+
766+
assert_equal %w(artist_id music_id), connection.columns(:artists_musics).map(&:name).sort
767+
end
768+
762769
end

0 commit comments

Comments
 (0)