diff options
author | Azul <azul@leap.se> | 2012-11-26 16:34:46 +0100 |
---|---|---|
committer | Azul <azul@leap.se> | 2012-11-26 16:34:46 +0100 |
commit | 51ba799f98113b7112f2968fc80e4d291924b3bf (patch) | |
tree | 257c1a21251b526c02b3cf1ef825384ef25cee51 /users/app/controllers/users_controller.rb | |
parent | bf74255d1530fe5852dc6e6c27ef975ce9aa8d3c (diff) |
basic users index with typeahead search
Diffstat (limited to 'users/app/controllers/users_controller.rb')
-rw-r--r-- | users/app/controllers/users_controller.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/users/app/controllers/users_controller.rb b/users/app/controllers/users_controller.rb index 4912ac8..09199f0 100644 --- a/users/app/controllers/users_controller.rb +++ b/users/app/controllers/users_controller.rb @@ -8,7 +8,13 @@ class UsersController < ApplicationController respond_to :json, :html def index - @users = User.all + if params[:query] + @users = User.by_login.startkey(params[:query]).endkey(params[:query].succ) + else + @users = User.by_created_at.descending + end + @users = @users.limit(5) + respond_with @users.map(&:login).sort end def new |