Skip to content

Models with Devise::Models::Authenticatable have degraded pretty-printing #5274

@hibachrach

Description

@hibachrach

Environment

  • Ruby 2.5.8
  • Rails 6.0.3.1
  • Devise 4.7.1

Current behavior

class AuthenticatableUser < ActiveRecord::Base
  devise :database_authenticatable
end

pp AuthenticatableUser.first
=begin
#<AuthenticatableUser id: 1, name: "Greg Grimaldus", email: "greg@example.com", nested_field: 
=end

Additionally, the output is all one color in a REPL like Pry.

Expected behavior

class NonAuthenticatableUser < ActiveRecord::Base
end

pp NonAuthenticatableUser.first
=begin
#<NonAuthenticatableUser
 id: 1,
 name: "Greg Grimaldus",
 email: "greg@example.com",
 nested_field:
  #<NestedField:0x0ab88383223
   @nested_field_attr=1>,
 ...MANY_MORE_FIELDS...>
=end 

Additionally, in a REPL like Pry, each attribute has color highlighting based on the value type.

Cause

The reason this occurs is because Devise::Models::Authenticatable overrides inspect and if the method is overriden, then ActiveRecord::Core#pretty_print defers to super. This is probably PP::ObjectMixin#pretty_print, which doesn't have the niceties described in the "Expected behavior" section.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions