admin area -> search for users

This commit is contained in:
randx 2012-06-21 19:05:09 +03:00
parent 98a45ce6ee
commit 1903f6ade0
3 changed files with 8 additions and 0 deletions

View file

@ -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

View file

@ -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
#

View file

@ -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