The active record determines which attributes should be displayed when checking based on the columns in the database table:
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}>"
end
Picked up from base.rb on github
To change the output of a check, you will have to overwrite it with your own method, for example.
def inspect
"#{super}, @foo = #{@foo}"
end
What should be output:
> Blog.first.inspect
=> "#<Blog id: 1, title: 'Test', created_at: nil, updated_at: nil>, @foo = 'bar'"
source
share