我正在使用Rails5。如何使用此模型...
class Book 作者类具有属性“名称”。如何为作者包含字符串“ Joe”的书对象编写查询?我尝试过此 但没有骰子。has_one :author
Book.includes(:author).where(:author => [ "LOWER(name) LIKE :search", :search[Dch => "%joe%"])
Book.joins(:author).where('LOWER(authors.name) LIKE ?', '%joe%')
plural_table_name.column_name LIKE ...
应该可以。