Refactor topics controller. Add Common abilities. Add destroy action.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user