Skip to content
Browse files

call to_s on value passed to table_name=

Signed-off-by: José Valim <jose.valim@gmail.com>
  • Loading branch information...
1 parent 1a93eaa commit 36d7af34d6e878a4557ba8a2c282609da2f646ba @lest lest committed with josevalim Jan 26, 2012
Showing with 6 additions and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/model_schema.rb
  2. +5 −0 activerecord/test/cases/base_test.rb
View
2 activerecord/lib/active_record/model_schema.rb
@@ -119,7 +119,7 @@ def original_table_name #:nodoc:
# 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)
View
5 activerecord/test/cases/base_test.rb
@@ -1448,6 +1448,11 @@ def test_switching_between_table_name
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)

0 comments on commit 36d7af3

Please sign in to comment.
Something went wrong with that request. Please try again.