Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有什么方法可以将集合(列表、数组或哈希)保留在模型的列中,这样我就可以进行如下查询
Model.where( collection.include? 'foo')
或者有没有办法模拟这个?
是的,有可能:
Model.where(:colname => "#{collection.include?("foo")}")
字符串插值可以实现这样的事情。