Skip to content

Commit

Permalink
call to_s on value passed to table_name=
Browse files Browse the repository at this point in the history
  • Loading branch information
lest committed Jan 26, 2012
1 parent ba5a334 commit db48ee3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/model_schema.rb
Expand Up @@ -115,7 +115,7 @@ def table_name
# 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)
Expand Down
5 changes: 5 additions & 0 deletions activerecord/test/cases/base_test.rb
Expand Up @@ -1446,6 +1446,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)

Expand Down

0 comments on commit db48ee3

Please sign in to comment.