attributes というメソッドがあります。
pry(main)> Book.first
Book Load (10.4ms) SELECT "books".* FROM "books" ORDER BY "books"."id" ASC LIMIT ? [["LIMIT", 1]]
+----+--------+--------+------+-------------------------+-------------------------+
| id | name | author | page | created_at | updated_at |
+----+--------+--------+------+-------------------------+-------------------------+
| 1 | book-1 | | | 2017-01-22 10:16:02 UTC | 2017-01-22 10:16:02 UTC |
+----+--------+--------+------+-------------------------+-------------------------+
1 row in set
[3] pry(main)> Book.first.attributes
Book Load (0.1ms) SELECT "books".* FROM "books" ORDER BY "books"."id" ASC LIMIT ? [["LIMIT", 1]]
=> {"id"=>1,
"name"=>"book-1",
"author"=>nil,
"page"=>nil,
"created_at"=>Sun, 22 Jan 2017 10:16:02 UTC +00:00,
"updated_at"=>Sun, 22 Jan 2017 10:16:02 UTC +00:00}
参考情報
... モデルの全てのカラムと属性を取得する ...
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。