We were defining the same filters in three different controllers. We were also adding a method in the ApplicationController which only made sense in the same three controllers.
27 lines
592 B
Ruby
27 lines
592 B
Ruby
module Budgets
|
|
class GroupsController < ApplicationController
|
|
include InvestmentFilters
|
|
|
|
before_action :load_budget
|
|
before_action :load_group
|
|
authorize_resource :budget
|
|
authorize_resource :group, class: "Budget::Group"
|
|
|
|
before_action :set_default_investment_filter, only: :show
|
|
has_filters investment_filters, only: [:show]
|
|
|
|
def show
|
|
end
|
|
|
|
private
|
|
|
|
def load_budget
|
|
@budget = Budget.find_by_slug_or_id! params[:budget_id]
|
|
end
|
|
|
|
def load_group
|
|
@group = @budget.groups.find_by_slug_or_id! params[:id]
|
|
end
|
|
end
|
|
end
|