diff options
-rw-r--r-- | activerecord/lib/active_record/model_schema.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/base_test.rb | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/model_schema.rb b/activerecord/lib/active_record/model_schema.rb index 0e8c2c09ce..1517e5ec17 100644 --- a/activerecord/lib/active_record/model_schema.rb +++ b/activerecord/lib/active_record/model_schema.rb @@ -119,7 +119,7 @@ module ActiveRecord # the documentation for ActiveRecord::Base#table_name. def table_name=(value) @original_table_name = @table_name if defined?(@table_name) - @table_name = value + @table_name = value && value.to_s @quoted_table_name = nil @arel_table = nil @relation = Relation.new(self, arel_table) diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 1cc815794f..703bb7eb5c 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -1448,6 +1448,11 @@ class BasicsTest < ActiveRecord::TestCase end end + def test_set_table_name_symbol_converted_to_string + Joke.table_name = :cold_jokes + assert_equal 'cold_jokes', Joke.table_name + end + def test_quoted_table_name_after_set_table_name klass = Class.new(ActiveRecord::Base) |