Extract concern to handle investments filters
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.
This commit is contained in:
17
app/controllers/concerns/investment_filters.rb
Normal file
17
app/controllers/concerns/investment_filters.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
module InvestmentFilters
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
class_methods do
|
||||
def investment_filters
|
||||
%w[not_unfeasible feasible unfeasible unselected selected winners]
|
||||
end
|
||||
end
|
||||
|
||||
def set_default_investment_filter
|
||||
if @budget&.balloting? || @budget&.publishing_prices?
|
||||
params[:filter] ||= "selected"
|
||||
elsif @budget&.finished?
|
||||
params[:filter] ||= "winners"
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user