aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/attribute_methods/primary_key.rb
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2011-08-05 18:42:41 -0300
committerSantiago Pastorino <santiago@wyeworks.com>2011-08-05 19:39:19 -0300
commit1b676fc76074047f4784502a9597fb529fd74dd7 (patch)
treeb9f8c31f7a5a1152bc624a5c66cb817028cf4aea /activerecord/lib/active_record/attribute_methods/primary_key.rb
parente0a6ec214987882a47722e709a91b17b8395bec9 (diff)
downloadrails-1b676fc76074047f4784502a9597fb529fd74dd7.tar.gz
rails-1b676fc76074047f4784502a9597fb529fd74dd7.tar.bz2
rails-1b676fc76074047f4784502a9597fb529fd74dd7.zip
Revert "to_key on a destroyed model should return nil". Closes #2440
This reverts commit c5448721b5054b8a467958d60427fdee15eac604.
Diffstat (limited to 'activerecord/lib/active_record/attribute_methods/primary_key.rb')
-rw-r--r--activerecord/lib/active_record/attribute_methods/primary_key.rb5
1 files changed, 2 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/primary_key.rb b/activerecord/lib/active_record/attribute_methods/primary_key.rb
index 8bd898d126..ed71b5e7d4 100644
--- a/activerecord/lib/active_record/attribute_methods/primary_key.rb
+++ b/activerecord/lib/active_record/attribute_methods/primary_key.rb
@@ -3,11 +3,10 @@ module ActiveRecord
module PrimaryKey
extend ActiveSupport::Concern
- # Returns this record's primary key value wrapped in an Array or nil if
- # the record is not persisted? or has just been destroyed.
+ # Returns this record's primary key value wrapped in an Array if one is available
def to_key
key = send(self.class.primary_key)
- persisted? && key ? [key] : nil
+ [key] if key
end
module ClassMethods