[英]Search working on full search only not a partial search ruby on rails
I have the following search query我有以下搜索查询
where("contact_type = 'supplier' and name = '#{search}'")
Let's say I'm searching for John
for John Doe
this doesn't work, however, if I search for the full name John Doe
the search works.假设我正在为John Doe
搜索John
,这不起作用,但是,如果我搜索全名John Doe
,则搜索有效。 How do I get it so I can do a partial search while retaining the current query?如何获取它以便在保留当前查询的同时进行部分搜索?
You have to try like
query:您必须尝试like
查询:
where("contact_type = 'supplier' and name like ?", "%#{search}%")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.