Remove redundant method to set order
It was being incorrectly detected as used in a dangerous send. We can get rid of the warning by taking advantage of the `has_orders` method and getting rid of this code.
This commit is contained in:
@@ -1,8 +1,6 @@
|
|||||||
class CommunitiesController < ApplicationController
|
class CommunitiesController < ApplicationController
|
||||||
TOPIC_ORDERS = %w[newest most_commented oldest].freeze
|
has_orders %w[newest most_commented oldest]
|
||||||
before_action :set_order, :set_community, :load_topics, :load_participants
|
before_action :set_community, :load_topics, :load_participants
|
||||||
|
|
||||||
has_orders TOPIC_ORDERS
|
|
||||||
|
|
||||||
skip_authorization_check
|
skip_authorization_check
|
||||||
|
|
||||||
@@ -14,26 +12,18 @@ class CommunitiesController < ApplicationController
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def set_order
|
|
||||||
@order = valid_order? ? params[:order] : "newest"
|
|
||||||
end
|
|
||||||
|
|
||||||
def set_community
|
def set_community
|
||||||
@community = Community.find(params[:id])
|
@community = Community.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_topics
|
def load_topics
|
||||||
@topics = @community.topics.send("sort_by_#{@order}").page(params[:page])
|
@topics = @community.topics.send("sort_by_#{@current_order}").page(params[:page])
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_participants
|
def load_participants
|
||||||
@participants = @community.participants
|
@participants = @community.participants
|
||||||
end
|
end
|
||||||
|
|
||||||
def valid_order?
|
|
||||||
params[:order].present? && TOPIC_ORDERS.include?(params[:order])
|
|
||||||
end
|
|
||||||
|
|
||||||
def communitable_exists?
|
def communitable_exists?
|
||||||
@community.proposal.present? || @community.investment.present?
|
@community.proposal.present? || @community.investment.present?
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user