Improved order.

This commit is contained in:
Martin Edenhofer 2016-09-12 08:52:01 +02:00
parent 19cb76bb12
commit a5b33a0e32

View file

@ -72,11 +72,11 @@ returns
users = if params[:role_ids] users = if params[:role_ids]
User.joins(:roles).where('roles.id' => params[:role_ids]).where( User.joins(:roles).where('roles.id' => params[:role_ids]).where(
'(users.firstname LIKE ? OR users.lastname LIKE ? OR users.email LIKE ? OR users.login LIKE ?) AND users.id != 1', "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%" '(users.firstname LIKE ? OR users.lastname LIKE ? OR users.email LIKE ? OR users.login LIKE ?) AND users.id != 1', "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%"
).order('firstname').limit(limit) ).order('updated_at DESC').limit(limit)
else else
User.where( User.where(
'(firstname LIKE ? OR lastname LIKE ? OR email LIKE ? OR login LIKE ?) AND id != 1', "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%" '(firstname LIKE ? OR lastname LIKE ? OR email LIKE ? OR login LIKE ?) AND id != 1', "%#{query}%", "%#{query}%", "%#{query}%", "%#{query}%"
).order('firstname').limit(limit) ).order('updated_at DESC').limit(limit)
end end
users users
end end