class method self.attributes_for_inspect

Ruby on Rails 8.1.2

Since v7.2.3

Available in: v7.2.3 v8.0.4 v8.1.2

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.

↑↓ navigate · open · esc close