aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2012-01-05 20:15:52 -0200
committerSantiago Pastorino <santiago@wyeworks.com>2012-01-05 20:16:09 -0200
commit675094b2757cf90399dadca4489b1036810ae570 (patch)
treece698136f7fdd6eb89b97376b78812955d9ae68f
parent0e8dda7eabb92384fb107b42339430f058166b7d (diff)
downloadrails-675094b2757cf90399dadca4489b1036810ae570.tar.gz
rails-675094b2757cf90399dadca4489b1036810ae570.tar.bz2
rails-675094b2757cf90399dadca4489b1036810ae570.zip
More 1.9 way
-rw-r--r--activemodel/lib/active_model/conversion.rb6
1 files changed, 2 insertions, 4 deletions
diff --git a/activemodel/lib/active_model/conversion.rb b/activemodel/lib/active_model/conversion.rb
index 80a3ba51c3..c7c805f1a2 100644
--- a/activemodel/lib/active_model/conversion.rb
+++ b/activemodel/lib/active_model/conversion.rb
@@ -39,11 +39,9 @@ module ActiveModel
# Returns an Enumerable of all key attributes if any is set, regardless
# if the object is persisted or not.
- #
- # Note the default implementation uses persisted? just because all objects
- # in Ruby 1.8.x responds to <tt>:id</tt>.
def to_key
- persisted? ? [id] : nil
+ key = respond_to?(:id) && id
+ key ? [key] : nil
end
# Returns a string representing the object's key suitable for use in URLs,