diff options
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods.rb | 4 | ||||
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/read.rb | 4 |
2 files changed, 3 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index 04a9932a4c..3eeb7fb4e9 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -148,9 +148,7 @@ module ActiveRecord end guard_private_attribute_method!(method_name, args) - if self.class.primary_key.to_s == method_name - id - elsif md = self.class.match_attribute_method?(method_name) + if md = self.class.match_attribute_method?(method_name) attribute_name, method_type = md.pre_match, md.to_s if attribute_name == 'id' || @attributes.include?(attribute_name) __send__("attribute#{method_type}", attribute_name, *args, &block) diff --git a/activerecord/lib/active_record/attribute_methods/read.rb b/activerecord/lib/active_record/attribute_methods/read.rb index 7e92e0bd68..a3327dc083 100644 --- a/activerecord/lib/active_record/attribute_methods/read.rb +++ b/activerecord/lib/active_record/attribute_methods/read.rb @@ -62,6 +62,7 @@ module ActiveRecord # "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)). def read_attribute(attr_name) attr_name = attr_name.to_s + attr_name = self.class.primary_key if attr_name == 'id' if !(value = @attributes[attr_name]).nil? if column = column_for_attribute(attr_name) if unserializable_attribute?(attr_name, column) @@ -84,8 +85,7 @@ module ActiveRecord column = column_for_attribute(attr_name) self.class.send(:define_read_method, :id, attr_name, column) - # now that the method exists, call it - self.send attr_name.to_sym + id end # Returns true if the attribute is of a text column and marked for serialization. |