admin area -> search for users
This commit is contained in:
parent
98a45ce6ee
commit
1903f6ade0
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue