class method self.attributes_for_inspect

Ruby on Rails 8.1.3.1

Since v7.2.3.2

Available in: v7.2.3.2 v8.0.5.1 v8.1.3.1 edge

Specifies the attributes that will be included in the output of the #inspect method:

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

When set to :all inspect will list all the record’s attributes:

Post.attributes_for_inspect = :all
Post.first.inspect #=> "#<Post id: 1, title: "Hello, World!", published_at: "2023-10-23 14:28:11 +0000">"
Source
# File activerecord/lib/active_record/core.rb, line 118
      class_attribute :attributes_for_inspect, instance_accessor: false, default: :all

Defined in activerecord/lib/active_record/core.rb line 118 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::Core

Type at least 2 characters to search.

Use the arrow keys to navigate results, Enter to open one, Escape to close.

Keyboard shortcuts

/
Focus search
⌘K / Ctrl-K
Command palette
?
This help
Esc
Close