Skip to content
This repository
Browse code

Do not in place modify what table_name returns

  • Loading branch information...
commit 7717fc375ee45d7cb1fa1672713ab8c883a833ef 1 parent 7222786
Santiago Pastorino authored March 18, 2011
2  activemodel/lib/active_model/attribute_methods.rb
@@ -102,7 +102,7 @@ def define_attr_method(name, value=nil, &block)
102 102
           sing.send :define_method, name, &block
103 103
         else
104 104
           value = value.to_s if value
105  
-          sing.send(:define_method, name) { value && value.dup }
  105
+          sing.send(:define_method, name) { value }
106 106
         end
107 107
       end
108 108
 
11  activemodel/test/cases/attribute_methods_test.rb
@@ -9,10 +9,6 @@ class << self
9 9
     define_method(:bar) do
10 10
       'original bar'
11 11
     end
12  
-
13  
-    define_method(:zomg) do
14  
-      'original zomg'
15  
-    end
16 12
   end
17 13
 
18 14
   def attributes
@@ -88,13 +84,6 @@ class AttributeMethodsTest < ActiveModel::TestCase
88 84
     assert_equal "value of foo bar", ModelWithAttributesWithSpaces.new.send(:'foo bar')
89 85
   end
90 86
 
91  
-  def test_defined_methods_always_return_duped_string
92  
-    ModelWithAttributes.define_attr_method(:zomg, 'lol')
93  
-    assert_equal 'lol', ModelWithAttributes.zomg
94  
-    ModelWithAttributes.zomg << 'bbq'
95  
-    assert_equal 'lol', ModelWithAttributes.zomg
96  
-  end
97  
-
98 87
   test '#define_attr_method generates attribute method' do
99 88
     ModelWithAttributes.define_attr_method(:bar, 'bar')
100 89
 
2  activerecord/lib/active_record/base.rb
@@ -959,7 +959,7 @@ def compute_table_name
959 959
             if parent < ActiveRecord::Base && !parent.abstract_class?
960 960
               contained = parent.table_name
961 961
               contained = contained.singularize if parent.pluralize_table_names
962  
-              contained << '_'
  962
+              contained += '_'
963 963
             end
964 964
             "#{full_table_name_prefix}#{contained}#{undecorated_table_name(name)}#{table_name_suffix}"
965 965
           else

0 notes on commit 7717fc3

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