diff options
author | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-07-04 23:11:47 -0500 |
---|---|---|
committer | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-07-04 23:11:47 -0500 |
commit | 6e00099a28f3271befff03b5ebbb8e6e561cdcd0 (patch) | |
tree | 8fa8966e82c8f81ee5811df6d205a754182114c6 | |
parent | b70f4277db15ce7d4944a86f96e451cb59645456 (diff) | |
download | rails-6e00099a28f3271befff03b5ebbb8e6e561cdcd0.tar.gz rails-6e00099a28f3271befff03b5ebbb8e6e561cdcd0.tar.bz2 rails-6e00099a28f3271befff03b5ebbb8e6e561cdcd0.zip |
update ActiveModel::Conversion documentation [ci skip]
-rw-r--r-- | activemodel/lib/active_model/conversion.rb | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/activemodel/lib/active_model/conversion.rb b/activemodel/lib/active_model/conversion.rb index 89d87a8b6f..57b1bc2ada 100644 --- a/activemodel/lib/active_model/conversion.rb +++ b/activemodel/lib/active_model/conversion.rb @@ -45,18 +45,30 @@ module ActiveModel # Returns an Enumerable of all key attributes if any is set, regardless if # the object is persisted or not. If there no key attributes, returns +nil+. + # + # class Person < ActiveRecord::Base + # end + # + # person = Person.create + # person.to_key # => [1] def to_key key = respond_to?(:id) && id key ? [key] : nil end - # Returns a string representing the object's key suitable for use in URLs, - # or +nil+ if <tt>persisted?</tt> is false. + # Returns a +string+ representing the object's key suitable for use in URLs, + # or +nil+ if <tt>persisted?</tt> is +false+. + # + # class Person < ActiveRecord::Base + # end + # + # person = Person.create + # person.to_param # => "1" def to_param persisted? ? to_key.join('-') : nil end - # Returns a string identifying the path associated with the object. + # Returns a +string+ identifying the path associated with the object. # ActionPack uses this to find a suitable partial to represent the object. # # class Person |