aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activemodel/lib/active_model/conversion.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/activemodel/lib/active_model/conversion.rb b/activemodel/lib/active_model/conversion.rb
index bfceb23852..21e4eb3c86 100644
--- a/activemodel/lib/active_model/conversion.rb
+++ b/activemodel/lib/active_model/conversion.rb
@@ -49,7 +49,8 @@ module ActiveModel
# person = Person.create
# person.to_key # => [1]
def to_key
- [id] if respond_to?(:id) && id
+ key = respond_to?(:id) && id
+ key ? [key] : nil
end
# Returns a +string+ representing the object's key suitable for use in URLs,