我有一个名为players的模型,它有一个hstore names played_positions
当我做Player.last时,我会得到
Player.last
#<Player:0x007fa281c04bc8> {
:id => 4239,
:first_name => "Deborah",
:last_name => "Rutherford",
:nickname => "Eulah",
:played_positions => {
"position" => "OL"
}
{在我的迁移文件中
add_column :players, :played_positions, :text在我的模型中我有
store :played_positions感谢你所有的帮助
发布于 2013-12-17 23:59:33
这将为您提供位置为OL的所有球员
Player.where("played_positions -> 'position' = 'OL'")https://stackoverflow.com/questions/20638167
复制相似问题