Ruby on rails 在ActiveRecord中使用SQL函数和

Ruby on rails 在ActiveRecord中使用SQL函数和,ruby-on-rails,ruby,postgresql,activerecord,Ruby On Rails,Ruby,Postgresql,Activerecord,我正试着做类似的事情 SELECT * FROM workers w WHERE lower(w.name) IN ('david', 'will', 'tom') 我将ActiveRecord和postgresDB与ruby(v2+)和rails(v4+)一起使用 我试着: Worker.select("lower(trim(name)) as n").where({ n: ['david', 'will', 'tom'] }).all 而且 Worker.where("lower(tri

我正试着做类似的事情

SELECT *
FROM workers w
WHERE lower(w.name) IN ('david', 'will', 'tom')
我将ActiveRecord和postgresDB与ruby(v2+)和rails(v4+)一起使用 我试着:

Worker.select("lower(trim(name)) as n").where({ n: ['david', 'will', 'tom'] }).all
而且

Worker.where("lower(trim(name))=:name", { name: ['david', 'will', 'tom'] }).all
但似乎什么都不管用。 有什么帮助吗?谢谢

这样试试

Worker.where("lower(trim(name)) IN (?)", ['david', 'will', 'tom'])
这样试试

Worker.where("lower(trim(name)) IN (?)", ['david', 'will', 'tom'])