使用 Sequel table_name.all 时获取行的结果

Getting the results of the row when using Sequel table_name.all

我正在尝试使用 Sequel 检索我的 table 的所有行:

puts MyApp::Model::SystemStatus.all

当我在我的控制台中打印出来时,我得到以下信息:

#<MyApp::Model::SystemStatus:0x6ac154ff>
#<MyApp::Model::SystemStatus:0x63d4d172>
#<MyApp::Model::SystemStatus:0x46d7f284>

我的问题是 - 如何让它打印出每列的所有信息,而不仅仅是行的散列?

例如,每个 SystemStatus 行都有以下列:

| id | is_valid | message | created_date |

如果要打印整个模型的所有属性,那么puts必须一起使用inspect:

puts MyApp::Model::SystemStatus.all.inspect

或者使用 p,或者只是离开控制台 returns 你 MyApp::Model::SystemStatus.all contains.

此外,如果您只想 select 某些属性,则可以使用 select:

MyApp::Model::SystemStatus.select(:id, :is_valid, :message, :created_date)