Refactor topics controller. Add Common abilities. Add destroy action.

This commit is contained in:
taitus
2017-09-06 13:30:12 +02:00
parent 5ea16976f7
commit 64774b0d2d
10 changed files with 76 additions and 13 deletions

View File

@@ -1,13 +1,13 @@
class TopicsController < ApplicationController
include CommentableActions
include FlagActions
before_action :load_community
before_action :load_topic, only: [:show, :edit, :update]
before_action :load_topic, only: [:show, :edit, :update, :destroy]
has_orders %w{most_voted newest oldest}, only: :show
skip_authorization_check
skip_authorization_check only: :show
load_and_authorize_resource except: :show
def new
@topic = Topic.new
@@ -39,6 +39,11 @@ class TopicsController < ApplicationController
end
end
def destroy
@topic.destroy
redirect_to community_path(@community), notice: I18n.t('flash.actions.destroy.topic')
end
private
def topic_params