有没有办法创建这样的条件?
@products = Product.find(:all,:limit => 5,:conditions => { :products => { :locale => 'en',:id NOT '1' },:tags => { :name => ['a','b']})
我想列出所有不包括产品的产品1.
谢谢.
解决方法
轨道3
使用squeel宝石.
Product.where( :products => { :locale => 'en',:id.not_in => '1' },'b']} ).limit(5)
轨道2
为此使用AR Extensions.它支持以下条件修饰符:
* _lt => less than * _gt => greater than * _lte => less than or equal to * _gte => greater than or equal to * _ne => not equal to * _not => not equal to
现在可以重写您的查询如下:
@products = Product.find(:all,:joins => [:tags],:conditions => { :locale => 'en',:id_not => '1','b']} )
原文地址:https://www.jb51.cc/ruby/266020.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。