我在这里做错了什么?
features = WidgetFeature.all(:conditions => {:widget_id=>params[:id], :children_features=>nil, :filterable => true" })
我想找到所有这些功能,其中widget_id = params [:id] AND children_features IS NIL AND filterable IS TRUE
答案 0 :(得分:0)
features = WidgetFeature.all(:conditions => {:widget_id=>params[:id], :children_features=>nil, :filterable => true })
这很有效。我解决了。
答案 1 :(得分:0)
试试这个:
features = WidgetFeature.find(:all, :conditions => "[widget_id=? and children_features is NULL and filterable = true", params[:id] ]")
这会对你有帮助..
答案 2 :(得分:0)
在我看来,最好的方法是
WidgetFeature.some_name_for_named_scope(PARAMS [:ID])
IN WidgetFeature Model
named_scope:some_name_for_named_scope,lambda {| widget_id | {:conditions => [“widget_id =?AND children_features =?AND filterable =?”,widget_id,nil,true]} }
请让我知道你或任何人的想法?