Refactoring method on debates controller
This commit is contained in:
@@ -9,6 +9,7 @@ module CommentableActions
|
||||
@resources = @resources.tagged_with(@tag_filter) if @tag_filter
|
||||
@resources = @resources.page(params[:page]).for_render.send("sort_by_#{@current_order}")
|
||||
index_customization if index_customization.present?
|
||||
featured_debates if featured_debates.present?
|
||||
|
||||
@tag_cloud = tag_cloud
|
||||
set_resource_votes(@resources)
|
||||
@@ -152,4 +153,9 @@ module CommentableActions
|
||||
def index_customization
|
||||
nil
|
||||
end
|
||||
|
||||
def featured_debates
|
||||
nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
class DebateLinksController < ApplicationController
|
||||
include FeatureFlags
|
||||
include CommentableActions
|
||||
|
||||
before_action :authenticate_user!, except: [:show]
|
||||
|
||||
load_and_authorize_resource class: "Debate"
|
||||
|
||||
feature_flag :debates
|
||||
|
||||
respond_to :html, :js
|
||||
|
||||
private
|
||||
|
||||
def create_params
|
||||
params.require(:debate).permit(:title, :external_link, :tag_list, :terms_of_service, :captcha, :captcha_key).merge(link_required: true)
|
||||
end
|
||||
|
||||
def debate_params
|
||||
params.require(:debate).permit(:title, :external_link, :tag_list, :terms_of_service, :captcha, :captcha_key).merge(link_required: true)
|
||||
end
|
||||
|
||||
def after_create_path
|
||||
debate_path(@resource)
|
||||
end
|
||||
|
||||
def resource_model
|
||||
Debate
|
||||
end
|
||||
|
||||
end
|
||||
@@ -18,11 +18,6 @@ class DebatesController < ApplicationController
|
||||
helper_method :resource_model, :resource_name
|
||||
respond_to :html, :js
|
||||
|
||||
def index
|
||||
super
|
||||
@featured_debates = @debates.featured
|
||||
end
|
||||
|
||||
def show
|
||||
super
|
||||
redirect_to debate_path(@debate), status: :moved_permanently if request.path != debate_path(@debate)
|
||||
@@ -43,6 +38,10 @@ class DebatesController < ApplicationController
|
||||
redirect_to request.query_parameters.merge(action: :index)
|
||||
end
|
||||
|
||||
def featured_debates
|
||||
@featured_debates = @debates.featured
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def debate_params
|
||||
|
||||
Reference in New Issue
Block a user