How to see the whole Model object attributes in rails console

Viewed 70

When I run:

[68] pry(main)> User.first

It returns:

=> #<User:0x411f4>

How do I configure rails/ruby to return all the model attributes like it did in rails 6?

ex:

=> #<User 
   id: 166,
   email: "hello@statecert.com",
   created_at: "2021-10-05 15:46:44.248514000 +0000",
   updated_at: "2021-10-05 15:47:22.193199000 +0000",
   first_name: "Danika",
   last_name: "LeBlanc", 
   notes: nil
   >
1 Answers

You can change this behaviour by setting inspect_mode to true

Open your .irbrc config file nano $HOME/.irbrc

And set INSPECT_MODE to true

IRB.conf[:INSPECT_MODE] = true

Examples:

# IRB.conf[:INSPECT_MODE] = false

=> #<User:0x411f4>
# IRB.conf[:INSPECT_MODE] = true

=> #<User 
   id: 166,
   email: "hello@statecert.com",
   created_at: "2021-10-05 15:46:44.248514000 +0000",
   updated_at: "2021-10-05 15:47:22.193199000 +0000",
   first_name: "Danika",
   last_name: "LeBlanc", 
   notes: nil
   >
Related