instance method
inspect
Ruby on Rails 6.0.6
Since v4.0.13Signature
inspect()
Returns the contents of the record as a nicely formatted string.
Source
# File activerecord/lib/active_record/core.rb, line 511
def inspect
# We check defined?(@attributes) not to issue warnings if the object is
# allocated but not initialized.
inspection = if defined?(@attributes) && @attributes
self.class.attribute_names.collect do |name|
if has_attribute?(name)
attr = _read_attribute(name)
value = if attr.nil?
attr.inspect
else
attr = format_for_inspect(attr)
inspection_filter.filter_param(name, attr)
end
"#{name}: #{value}"
end
end.compact.join(", ")
else
"not initialized"
end
"#<#{self.class} #{inspection}>"
end
Defined in activerecord/lib/active_record/core.rb line 511
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Core