mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
parent
fd918fe5ed
commit
8350ce97f2
1 changed files with 4 additions and 2 deletions
|
@ -39,9 +39,11 @@ 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
|
||||
key = respond_to?(:id) && id
|
||||
key ? [key] : nil
|
||||
persisted? ? [id] : nil
|
||||
end
|
||||
|
||||
# Returns a string representing the object's key suitable for use in URLs,
|
||||
|
|
Loading…
Reference in a new issue