Uses has_filters in all controllers with filters & renames @filter to @current_filter

This commit is contained in:
kikito
2015-09-02 13:21:46 +02:00
parent 83d08b0017
commit ebacc8c9c7
13 changed files with 26 additions and 80 deletions

View File

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