I'm trying to retrieve all the rows of my table using Sequel with the following:
puts MyApp::Model::SystemStatus.all
When I print this out in my console, I get the following:
#<MyApp::Model::SystemStatus:0x6ac154ff>
#<MyApp::Model::SystemStatus:0x63d4d172>
#<MyApp::Model::SystemStatus:0x46d7f284>
My question is - how do I get it to print out all information from each column instead of just a hash of the row?
For example, each SystemStatus
row has the following columns:
| id | is_valid | message | created_date |
If you want to print all the attribute when using all over a model, then puts
must be used together inspect
:
puts MyApp::Model::SystemStatus.all.inspect
Or using p
, or just leaving the console returns you what MyApp::Model::SystemStatus.all contains.
Also if you want just to select some attribute then you can use select:
MyApp::Model::SystemStatus.select(:id, :is_valid, :message, :created_date)