开发者

Rails and Searchlogic: finding products that matching all given product categories by using searchlogic condition

I have a model Publication and a model Category in my Rails app. Both are connected with a has_and_belongs_to_many association.

Now I would like to search publications that match one or more categories. If more than one category is given they have all assigned to the publication. I want to specify the categories in a multiple select_box.

Publication.released.categories_id_is([1,2]) is not working because the categories are connected with OR.

With Publication.categories_id_is_all([1,2]) the categories are connected with AND, but no result is given back.

Any idea's on that? Am I mising the right point 开发者_开发百科in the docs. Thanks for your very welcome help!


Take a look at the logs to see what SQL query is actually being run for those commands.

You may want to try

Publication.categories_id_equals_all([1,2])

As the is shortcut could be causing a problem there

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜