Added ransack search function to admin/users index
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
class Admin::JobsController < ApplicationController
|
||||
include Pagy::Backend
|
||||
|
||||
before_action :authorize!
|
||||
def index
|
||||
@jobs = Job.all
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
class Admin::UsersController < ApplicationController
|
||||
include Pagy::Backend
|
||||
|
||||
before_action :set_user, only: [ :show, :update ]
|
||||
before_action :authorize!
|
||||
|
||||
def index
|
||||
@users = User.all.order(:lastname, :firstname)
|
||||
@pagy, @records = pagy(@users, limit: 20)
|
||||
# @users = User.all.order(:lastname, :firstname)
|
||||
@q = User.ransack(params[:q])
|
||||
@q.sorts = "id asc" if @q.sorts.empty?
|
||||
@pagy, @records = pagy(@q.result(distinct: true), limit: 20)
|
||||
end
|
||||
|
||||
def edit
|
||||
@@ -23,7 +27,7 @@ class Admin::UsersController < ApplicationController
|
||||
authorize! @user
|
||||
if @user.update(user_params)
|
||||
respond_to do |format|
|
||||
format.html { redirect_to admin_users_path }
|
||||
format.html { redirect_back(fallback_location: admin_users_path) }
|
||||
end
|
||||
else
|
||||
render :index, status: :unprocessable_entity
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
include Pagy::Backend
|
||||
|
||||
before_action :set_current_request_details
|
||||
before_action :authenticate_user!
|
||||
before_action :verified_user!
|
||||
|
||||
Reference in New Issue
Block a user