如何将条件“LIKE?%something%”添加到此联接的产品标题中

时间:2010-08-11 14:37:51

标签: mysql ruby-on-rails

Product.find(:all,
    :conditions => { :companies => { :malls => { :id => 1},:products => {:title => "nexus one"} }},
    :joins => [:company => :mall])

1 个答案:

答案 0 :(得分:1)

我找到了解决方案,我想我必须休息一下,

Product.find(:all,:conditions => ['title LIKE ? and mall_id = ?', "%#{search}%",mall_id],
        :joins => [:company => :mall])