Rails ActiveRecord conditions

后端 未结 4 1268
误落风尘
误落风尘 2020-12-15 11:26

Is there a way to create a condition like this?

@products = Product.find(:all,
  :limit => 5,
  :conditions => { :products => { :locale => \'en\'         


        
4条回答
  •  渐次进展
    2020-12-15 11:51

    It should be something like this. The original query wasn't really clear, adapt it to your needs.

    @products = Product.find(:all,
      :limit => 5,
      :conditions => ["locale = ? AND id <> ? AND tags.name IN (?)", "en", 1, ['a','b'],
      :joins => "tags"
    )
    

提交回复
热议问题