aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/base.rb
diff options
context:
space:
mode:
authorFranck Verrot <franck@verrot.fr>2011-05-25 13:52:25 +0200
committerFranck Verrot <franck@verrot.fr>2011-05-25 13:54:38 +0200
commitb2db8740eabbb9b9c6afb237530d33ef7fc807e9 (patch)
tree2dea07f6d5c009ea0c2ee062f0bc8af90948e5ce /activerecord/lib/active_record/base.rb
parentbf159aa5fc9ed4d68c4975dab37dfaf58d29a08c (diff)
downloadrails-b2db8740eabbb9b9c6afb237530d33ef7fc807e9.tar.gz
rails-b2db8740eabbb9b9c6afb237530d33ef7fc807e9.tar.bz2
rails-b2db8740eabbb9b9c6afb237530d33ef7fc807e9.zip
Fix the AR::Base#inspect method [closes #1294]
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rw-r--r--activerecord/lib/active_record/base.rb16
1 files changed, 10 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 99930e7697..cb2c621c79 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1870,12 +1870,16 @@ MSG
# Returns the contents of the record as a nicely formatted string.
def inspect
- attributes_as_nice_string = self.class.column_names.collect { |name|
- if has_attribute?(name)
- "#{name}: #{attribute_for_inspect(name)}"
- end
- }.compact.join(", ")
- "#<#{self.class} #{attributes_as_nice_string}>"
+ inspection = if @attributes
+ self.class.column_names.collect { |name|
+ if has_attribute?(name)
+ "#{name}: #{attribute_for_inspect(name)}"
+ end
+ }.compact.join(", ")
+ else
+ "not initialized"
+ end
+ "#<#{self.class} #{inspection}>"
end
protected