如何调试用户对象?
我正在使用 byebug。我想访问名称属性,但我得到了类名用户。
请帮忙
谢谢
[8, 17] in /home/ubuntu/workspace/converse/app/controllers/messages_controller.rb
8: end
9:
10: def new1
11: @msguser = User.where(id: params['recipients'])
12: byebug
=> 13: @recid = params['recipients']
14: end
15:
16: def create
17: recipients = User.where(id: params['recipients'])
(byebug)
(byebug) @msguser
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? [["id", 1]]
#<ActiveRecord::Relation [#<User id: 1, name: "sumar", email: "chuch@gmail.com", created_at: "2015-01-23 12:57:41", updated_at: "2015-01-23 12:59:13", password_digest: "$2a$10$xNvGKpPwspaeTd33QrTwuuLP0TesuuTmfbrUlFO7LDs...", remember_digest: nil, admin: false, date_of_birth: "1985-01-01 00:00:00", is_female: false, activation_digest: "$2a$10$nIwWkX2X8WugscC/Yre7KeWRIzw6ecNyA5hLn/xPw9C...", activated: true, activated_at: "2015-01-23 12:58:58", reset_digest: nil, reset_sent_at: nil, avatar_file_name: nil, avatar_content_type: nil, avatar_file_size: nil, avatar_updated_at: nil, country_id: 1, cover_file_name: nil, cover_content_type: nil, cover_file_size: nil, cover_updated_at: nil, intro: "hey">]>
(byebug) @msguser.name
"User"
(byebug)
我期待名字:“sumar”