I'm using searchkick in my rails app. When user types letters of the name he wants to find into form, I get it with params[:query]. The fields' names are (name, login, passwd). The result of searching returns in table. Something like this:
env1@something.com login1 passwd1
env1@something.com login2 passwd2
env2@something.com login1 passwd2
env2@something.com login2 passwd2
....
Searching works fine returning all matched names but the question is how can I get only those fields where the name matches query AND login = login1 for example?
Will appreciate your help. Thanks in advance.
该查询应有助于:
User.search(params[:query], where: {login: params[:login]})
@users = User.search "*", where: {name: params[:query], login: params[:login]}
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.