Keep a blank line before and after private Keep a blank line before and after protected Remove extra empty line at class body end Remove extra blank line Add final newline Use 2 (not 3) spaces for indentation Use 2 (not 4) spaces for indentation Remove space before comma Add space after comma Remove trailing whitespaces Remove unnecessary spacing Use snake_case for variable names Do not use then for multi-line if Remove unused block argument - i Use the new Ruby 1.9 hash syntax Remove unused assignment to variable Indent when as deep as case Align attributes Align end with def
58 lines
1.5 KiB
Ruby
58 lines
1.5 KiB
Ruby
class DebatesController < ApplicationController
|
|
include FeatureFlags
|
|
include CommentableActions
|
|
include FlagActions
|
|
|
|
before_action :parse_search_terms, only: [:index, :suggest]
|
|
before_action :parse_advanced_search_terms, only: :index
|
|
before_action :parse_tag_filter, only: :index
|
|
before_action :set_search_order, only: :index
|
|
before_action :authenticate_user!, except: [:index, :show, :map]
|
|
|
|
feature_flag :debates
|
|
|
|
invisible_captcha only: [:create, :update], honeypot: :subtitle
|
|
|
|
has_orders %w{hot_score confidence_score created_at relevance}, only: :index
|
|
has_orders %w{most_voted newest oldest}, only: :show
|
|
|
|
load_and_authorize_resource
|
|
helper_method :resource_model, :resource_name
|
|
respond_to :html, :js
|
|
|
|
def index_customization
|
|
@featured_debates = @debates.featured
|
|
@proposal_successfull_exists = Proposal.successfull.exists?
|
|
end
|
|
|
|
def show
|
|
super
|
|
redirect_to debate_path(@debate), status: :moved_permanently if request.path != debate_path(@debate)
|
|
end
|
|
|
|
def vote
|
|
@debate.register_vote(current_user, params[:value])
|
|
set_debate_votes(@debate)
|
|
end
|
|
|
|
def unmark_featured
|
|
@debate.update_attribute(:featured_at, nil)
|
|
redirect_to request.query_parameters.merge(action: :index)
|
|
end
|
|
|
|
def mark_featured
|
|
@debate.update_attribute(:featured_at, Time.now)
|
|
redirect_to request.query_parameters.merge(action: :index)
|
|
end
|
|
|
|
private
|
|
|
|
def debate_params
|
|
params.require(:debate).permit(:title, :description, :tag_list, :terms_of_service)
|
|
end
|
|
|
|
def resource_model
|
|
Debate
|
|
end
|
|
|
|
end |