【发布时间】:2013-04-01 23:24:23
【问题描述】:
我有一个产品模型和一个类别模型。产品 has_many_and_belongs_to 类别,反之亦然。现在我想使用 Product.find 来搜索 Product.name 和 Product.categories。我尝试了类似的方法,但没有成功:
Product.find(:all, :conditions => ['name LIKE ? or categories LIKE ?', '%#{keyword}%']
基本上,我正在尝试获取名称为“汽车”或类别为“汽车”的产品的结果。提前致谢!
【问题讨论】:
标签: ruby-on-rails ruby activerecord