简体   繁体   中英

Ransack with match exact word

I'm using ransack for search product like this :

Product.display_status.order('status asc').ransack(params[:q])

with combine predicates name_or_meta_tag_cont .

The problem is, that it selects more than i would like.

For example :

I would like to select product with keyword "foo bar", but my query select product with meta tag "foo barfoo, foo, bar" as well. To be clear, if i wanted to select product with meta tag "best product, bla, bla", I don't want the query to select "best products, bla, bla".

If I'm not use ransack :

Product.where("meta_tag ~* ? or name ~* ?", ' foo bar\\M', ' foo bar\\M')

Does anybody know how can I use that with ransack?

因此,您只需要具有“ foo bar”作为确切名称或元标记的产品?

name_or_meta_tag_eq

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM