diff options
author | Xavier Noria <fxn@hashref.com> | 2012-02-11 11:14:00 -0800 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2012-02-11 11:14:00 -0800 |
commit | 5138a8f254b865c2cf97b61848b640783366d26b (patch) | |
tree | ccacb2cb9d1f889e135ac6487fae227f994a266b | |
parent | 347e0a603308f1936d995ad0e7966e1de071e75f (diff) | |
parent | d7942d4230e7cfa0c0c7c96c9a10dee49f612155 (diff) | |
download | rails-5138a8f254b865c2cf97b61848b640783366d26b.tar.gz rails-5138a8f254b865c2cf97b61848b640783366d26b.tar.bz2 rails-5138a8f254b865c2cf97b61848b640783366d26b.zip |
Merge pull request #5006 from lest/patch-1
handle id attribute in PrimaryKey module
-rw-r--r-- | activerecord/lib/active_record/attribute_methods.rb | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/primary_key.rb | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/attribute_methods.rb b/activerecord/lib/active_record/attribute_methods.rb index 889c80386f..3e27e85f02 100644 --- a/activerecord/lib/active_record/attribute_methods.rb +++ b/activerecord/lib/active_record/attribute_methods.rb @@ -244,7 +244,7 @@ module ActiveRecord end def attribute_method?(attr_name) - attr_name == 'id' || (defined?(@attributes) && @attributes.include?(attr_name)) + defined?(@attributes) && @attributes.include?(attr_name) end end end diff --git a/activerecord/lib/active_record/attribute_methods/primary_key.rb b/activerecord/lib/active_record/attribute_methods/primary_key.rb index 7c59664703..2e1a2dc3ef 100644 --- a/activerecord/lib/active_record/attribute_methods/primary_key.rb +++ b/activerecord/lib/active_record/attribute_methods/primary_key.rb @@ -24,6 +24,12 @@ module ActiveRecord query_attribute(self.class.primary_key) end + protected + + def attribute_method?(attr_name) + attr_name == 'id' || super + end + module ClassMethods def define_method_attribute(attr_name) super |