0

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.

Gleb
  • 13
  • 5

2 Answers2

1
@users = User.search "*", where: {name: params[:query], login: params[:login]}
Dias
  • 862
  • 8
  • 17
0

This query should help:

User.search(params[:query], where: {login: params[:login]})
Aref Aslani
  • 1,560
  • 13
  • 27
Sharvy Ahmed
  • 7,247
  • 1
  • 33
  • 46