instance method pretty_print

Ruby on Rails 5.2.8.1

Since v4.2.9

Available in: v4.2.9 v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

pretty_print(pp)

Takes a PP and prettily prints this record to it, allowing you to get a nice result from pp record when pp is required.

Parameters

pp req
Source
# File activerecord/lib/active_record/core.rb, line 505
    def pretty_print(pp)
      return super if custom_inspect_method_defined?
      pp.object_address_group(self) do
        if defined?(@attributes) && @attributes
          column_names = self.class.column_names.select { |name| has_attribute?(name) || new_record? }
          pp.seplist(column_names, proc { pp.text "," }) do |column_name|
            column_value = read_attribute(column_name)
            pp.breakable " "
            pp.group(1) do
              pp.text column_name
              pp.text ":"
              pp.breakable
              pp.pp column_value
            end
          end
        else
          pp.breakable " "
          pp.text "not initialized"
        end
      end
    end

Defined in activerecord/lib/active_record/core.rb line 505 · 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