3

I am willing to call a method when trying to display an object, but I don't find which method is used, for example:

[41] pry(main)> u
=> {"id"=>3}
[42] pry(main)> u.inspect
=> "#<User id=3>"
[43] pry(main)> u.to_s
=> "#<User id=3>"
[44] pry(main)> puts c
#<User id=3>
=> nil

I would like to know which method is called for the first case.

User is not an ActiveRecord class, it inherits from Hashie.

Thanks for your help!

jrichardlai
  • 3,317
  • 4
  • 21
  • 24

1 Answers1

1

It's probably the rails method attributes - though it is a feature of Pry, not of the standard rails console which would give you ruby-1.9.2-p290 :047 > u => #<u:0x8a2f6cc @id=3>

chrispanda
  • 3,204
  • 1
  • 21
  • 23
  • +1, it seems that you right - 'Returns a hash of all the attributes with their names as keys and the values of the attributes as values.'at http://api.rubyonrails.org/classes/ActiveRecord/Base.html#method-i-attributes – WarHog Nov 05 '11 at 08:28
  • Thanks for the answer but it's not a Rails ActiveRecord Object, I don't use Rails here. Its a class that inherit from Hashie – jrichardlai Nov 05 '11 at 16:03