Skip to content

Commit

Permalink
Do not in place modify what table_name returns
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed Mar 22, 2011
1 parent 7222786 commit 7717fc3
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 13 deletions.
2 changes: 1 addition & 1 deletion activemodel/lib/active_model/attribute_methods.rb
Expand Up @@ -102,7 +102,7 @@ def define_attr_method(name, value=nil, &block)
sing.send :define_method, name, &block
else
value = value.to_s if value
sing.send(:define_method, name) { value && value.dup }
sing.send(:define_method, name) { value }
end
end

Expand Down
11 changes: 0 additions & 11 deletions activemodel/test/cases/attribute_methods_test.rb
Expand Up @@ -9,10 +9,6 @@ class << self
define_method(:bar) do
'original bar'
end

define_method(:zomg) do
'original zomg'
end
end

def attributes
Expand Down Expand Up @@ -88,13 +84,6 @@ class AttributeMethodsTest < ActiveModel::TestCase
assert_equal "value of foo bar", ModelWithAttributesWithSpaces.new.send(:'foo bar')
end

def test_defined_methods_always_return_duped_string
ModelWithAttributes.define_attr_method(:zomg, 'lol')
assert_equal 'lol', ModelWithAttributes.zomg
ModelWithAttributes.zomg << 'bbq'
assert_equal 'lol', ModelWithAttributes.zomg
end

test '#define_attr_method generates attribute method' do
ModelWithAttributes.define_attr_method(:bar, 'bar')

Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/base.rb
Expand Up @@ -959,7 +959,7 @@ def compute_table_name
if parent < ActiveRecord::Base && !parent.abstract_class?
contained = parent.table_name
contained = contained.singularize if parent.pluralize_table_names
contained << '_'
contained += '_'
end
"#{full_table_name_prefix}#{contained}#{undecorated_table_name(name)}#{table_name_suffix}"
else
Expand Down

0 comments on commit 7717fc3

Please sign in to comment.