Uses has_filters in all controllers with filters & renames @filter to @current_filter
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
class Admin::OrganizationsController < Admin::BaseController
|
||||
before_filter :set_valid_filters, only: :index
|
||||
before_filter :parse_filter, only: :index
|
||||
|
||||
has_filters %w{all pending verified rejected}, only: :index
|
||||
|
||||
load_and_authorize_resource except: :search
|
||||
|
||||
def index
|
||||
@organizations = @organizations.send(@filter)
|
||||
@organizations = @organizations.send(@current_filter)
|
||||
@organizations = @organizations.includes(:user).order(:name, 'users.email').page(params[:page])
|
||||
end
|
||||
|
||||
@@ -23,14 +23,4 @@ class Admin::OrganizationsController < Admin::BaseController
|
||||
redirect_to request.query_parameters.merge(action: :index)
|
||||
end
|
||||
|
||||
private
|
||||
def set_valid_filters
|
||||
@valid_filters = %w{all pending verified rejected}
|
||||
end
|
||||
|
||||
def parse_filter
|
||||
@filter = params[:filter]
|
||||
@filter = 'all' unless @valid_filters.include?(@filter)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user