aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2012-01-06 10:48:47 -0200
committerSantiago Pastorino <santiago@wyeworks.com>2012-01-06 11:04:18 -0200
commitfc956425d405e75bcf310f3e6f08cf201cc8131a (patch)
tree555056074044212c009f7797833aa6123ff9e6ce /activemodel/lib
parent6e6764b3a1479523eb352ca2baeed0a508ce954b (diff)
downloadrails-fc956425d405e75bcf310f3e6f08cf201cc8131a.tar.gz
rails-fc956425d405e75bcf310f3e6f08cf201cc8131a.tar.bz2
rails-fc956425d405e75bcf310f3e6f08cf201cc8131a.zip
Revert "Revert "More 1.9 way""
Fixed failing tests This reverts commit 8350ce97f2065eed9638c595d3938a573d6fa343.
Diffstat (limited to 'activemodel/lib')
-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,