Method: ActiveRecord::Core#inspect

Defined in:
activerecord/lib/active_record/core.rb

#inspectObject

Returns the attributes of the record as a nicely formatted string.

Post.first.inspect
#=> "#<Post id: 1, title: "Hello, World!", published_at: "2023-10-23 14:28:11 +0000">"

The attributes can be limited by setting .attributes_for_inspect.

Post.attributes_for_inspect = [:id, :title]
Post.first.inspect
#=> "#<Post id: 1, title: "Hello, World!">"


782
783
784
# File 'activerecord/lib/active_record/core.rb', line 782

def inspect
  inspect_with_attributes(attributes_for_inspect)
end