aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-05-25 05:02:15 -0700
committerJosé Valim <jose.valim@gmail.com>2011-05-25 05:02:15 -0700
commitb145a725f84b9f01a63370249f61c61725ab8927 (patch)
tree2dea07f6d5c009ea0c2ee062f0bc8af90948e5ce /activerecord/lib
parentb1bb9d17381c860653db50589774e83cb5c95293 (diff)
parentb2db8740eabbb9b9c6afb237530d33ef7fc807e9 (diff)
downloadrails-b145a725f84b9f01a63370249f61c61725ab8927.tar.gz
rails-b145a725f84b9f01a63370249f61c61725ab8927.tar.bz2
rails-b145a725f84b9f01a63370249f61c61725ab8927.zip
Merge pull request #1297 from cesario/1294-allocated-object-cant-be-inspected
#1294 : allocated object cant be inspected [closes #1294]
Diffstat (limited to 'activerecord/lib')
-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