Commit 1903f6ad authored by randx's avatar randx

admin area -> search for users

parent 98a45ce6
......@@ -6,6 +6,7 @@ class Admin::UsersController < ApplicationController
def index
@admin_users = User.scoped
@admin_users = @admin_users.filter(params[:filter])
@admin_users = @admin_users.search(params[:name]) if params[:name].present?
@admin_users = @admin_users.order("updated_at DESC").page(params[:page])
end
......
......@@ -83,6 +83,10 @@ class User < ActiveRecord::Base
)
end
end
def self.search query
where("name like :query or email like :query", :query => "%#{query}%")
end
end
# == Schema Information
#
......
......@@ -3,6 +3,9 @@
= link_to 'New User', new_admin_user_path, :class => "btn small right"
%br
= form_tag admin_users_path, :method => :get do
= text_field_tag :name, params[:name], :class => "xlarge"
= submit_tag "Search", :class => "btn submit primary"
%ul.nav.nav-pills
%li{:class => "#{'active' unless params[:filter]}"}
= link_to "Active", admin_users_path
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment