Added user search.
This commit is contained in:
parent
e52a489dc4
commit
07148462dd
1 changed files with 9 additions and 3 deletions
|
@ -41,9 +41,15 @@ returns
|
||||||
# fallback do sql query
|
# fallback do sql query
|
||||||
# - stip out * we already search for *query* -
|
# - stip out * we already search for *query* -
|
||||||
query.gsub! '*', ''
|
query.gsub! '*', ''
|
||||||
users = User.where(
|
if params[:role_ids]
|
||||||
'(firstname LIKE ? or lastname LIKE ? or email LIKE ?) AND id != 1', "%#{query}%", "%#{query}%", "%#{query}%",
|
users = User.joins(:roles).where( 'roles.id' => params[:role_ids] ).where(
|
||||||
).order('firstname').limit(limit)
|
'(users.firstname LIKE ? or users.lastname LIKE ? or users.email LIKE ?) AND users.id != 1', "%#{query}%", "%#{query}%", "%#{query}%",
|
||||||
|
).order('firstname').limit(limit)
|
||||||
|
else
|
||||||
|
users = User.where(
|
||||||
|
'(firstname LIKE ? or lastname LIKE ? or email LIKE ?) AND id != 1', "%#{query}%", "%#{query}%", "%#{query}%",
|
||||||
|
).order('firstname').limit(limit)
|
||||||
|
end
|
||||||
return users
|
return users
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue