aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/core.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2013-04-28 12:03:26 +0200
committerXavier Noria <fxn@hashref.com>2013-04-28 12:03:59 +0200
commit607f136d52e984323cbe2938c04c660ca55a5039 (patch)
tree85eb7a2764caa5f0c872bc27fbddbae7178bf2a9 /activerecord/lib/active_record/core.rb
parent31aab3ee57bc2cb31bcc0bf459c38b72d4ec3c24 (diff)
downloadrails-607f136d52e984323cbe2938c04c660ca55a5039.tar.gz
rails-607f136d52e984323cbe2938c04c660ca55a5039.tar.bz2
rails-607f136d52e984323cbe2938c04c660ca55a5039.zip
fixes a test, and explains why AR::AttributeMethods checks defined?(@attributes) in some places
Diffstat (limited to 'activerecord/lib/active_record/core.rb')
-rw-r--r--activerecord/lib/active_record/core.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/core.rb b/activerecord/lib/active_record/core.rb
index 9e45e6e474..ba053700f2 100644
--- a/activerecord/lib/active_record/core.rb
+++ b/activerecord/lib/active_record/core.rb
@@ -352,7 +352,9 @@ module ActiveRecord
# Returns the contents of the record as a nicely formatted string.
def inspect
- inspection = if @attributes
+ # We check defined?(@attributes) not to issue warnings if the object is
+ # allocated but not initialized.
+ inspection = if defined?(@attributes) && @attributes
self.class.column_names.collect { |name|
if has_attribute?(name)
"#{name}: #{attribute_for_inspect(name)}"