标签: ruby-on-rails postgresql activerecord
我有此查询,需要在此查询中使用,请帮助我。
scope:filter,->(查询){includes(:city).where(city:{name:query})}
答案 0 :(得分:1)
只需将字符串用作where的参数
where
scope :filter, -> (query) { joins(:city).where('cities.name LIKE ?', "%#{ query }%") }