aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorChris Kampmeier <chris@kampers.net>2009-01-11 20:28:15 -0800
committerChris Kampmeier <chris@kampers.net>2009-01-11 20:28:15 -0800
commit73db43527d162fdf95665d88589f7ab6d17a17fa (patch)
tree2290ee9dd2721e3177c5ae087777e8079373b16b /activerecord
parent10a35b0b1d9a7751b352c266387ae950cf9c47f4 (diff)
downloadrails-73db43527d162fdf95665d88589f7ab6d17a17fa.tar.gz
rails-73db43527d162fdf95665d88589f7ab6d17a17fa.tar.bz2
rails-73db43527d162fdf95665d88589f7ab6d17a17fa.zip
Add better docs for ActiveRecord::Base#attribute_for_inspect
Diffstat (limited to 'activerecord')
-rwxr-xr-xactiverecord/lib/active_record/base.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 4c57897c43..1ba09a96b5 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -2739,7 +2739,18 @@ module ActiveRecord #:nodoc:
end
end
- # Format attributes nicely for inspect.
+ # Returns an <tt>#inspect</tt>-like value for the value of the attribute
+ # referred to by +attr_name+. Strings are elided after 50 characters,
+ # and Dates and Times are returned in the <tt>:db</tt> format. Other
+ # attributes return the value of <tt>#inspect</tt> normally.
+ #
+ # person = Person.create!(:name => "David Heinemeier Hansson " * 3)
+ #
+ # person.attribute_for_inspect(:name)
+ # # => '"David Heinemeier Hansson David Heinemeier Hansson D..."'
+ #
+ # person.attribute_for_inspect(:created_at)
+ # # => '"2009-01-12 04:48:57"'
def attribute_for_inspect(attr_name)
value = read_attribute(attr_name)