Rails 3 和 mongo db (mongoid) 中的基本文本搜索
我有一些漂亮的 javascript 可以序列化搜索输入。
控制器有这个:
@recipes = Recipe.where(name: params[:q])
现在它只在存在精确的完整单词匹配时才返回结果 - 有谁知道如何使其返回可能包含 params[:q] 的结果,即使它不是精确的完整匹配?
即鸡肉应返回炖鸡、鸡肉馅饼等。
I have some nifty javascript that serializes search input.
the controller has this:
@recipes = Recipe.where(name: params[:q])
right now it only returns results when theres an exact full word match - does anyone know of a way to make it return results which might contain the params[:q] even if its not an exact full match?
i.e. chicken should return chicken stew, chicken pot pie, etc.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
Try this one: