Remove code to delete all comments on one line and restore default delete route for comments
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
class CommentsController < ApplicationController
|
class CommentsController < ApplicationController
|
||||||
before_action :set_comment, only: [:show, :edit, :update, :destroy_by_id]
|
before_action :set_comment, only: [:show, :edit, :update, :destroy]
|
||||||
|
|
||||||
# to disable authorization check: comment the line below back in
|
# to disable authorization check: comment the line below back in
|
||||||
# skip_after_action :verify_authorized
|
# skip_after_action :verify_authorized
|
||||||
@ -84,7 +84,8 @@ class CommentsController < ApplicationController
|
|||||||
|
|
||||||
# DELETE /comments/1
|
# DELETE /comments/1
|
||||||
# DELETE /comments/1.json
|
# DELETE /comments/1.json
|
||||||
def destroy_by_id
|
def destroy
|
||||||
|
authorize!
|
||||||
@comment.destroy
|
@comment.destroy
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { head :no_content, notice: 'Comment was successfully destroyed.' }
|
format.html { head :no_content, notice: 'Comment was successfully destroyed.' }
|
||||||
@ -92,16 +93,6 @@ class CommentsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
|
||||||
@comments = Comment.where(file_id: params[:file_id], row: params[:row], user: current_user)
|
|
||||||
@comments.each { |comment| authorize comment; comment.destroy }
|
|
||||||
respond_to do |format|
|
|
||||||
#format.html { redirect_to comments_url, notice: 'Comments were successfully destroyed.' }
|
|
||||||
format.html { head :no_content, notice: 'Comments were successfully destroyed.' }
|
|
||||||
format.json { head :no_content }
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
# Use callbacks to share common setup or constraints between actions.
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
def set_comment
|
def set_comment
|
||||||
|
@ -12,14 +12,10 @@ class CommentPolicy < ApplicationPolicy
|
|||||||
everyone
|
everyone
|
||||||
end
|
end
|
||||||
|
|
||||||
[:new?, :destroy?, :update?].each do |action|
|
[:new?, :destroy?, :update?, :edit?].each do |action|
|
||||||
define_method(action) { admin? || author? }
|
define_method(action) { admin? || author? }
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit?
|
|
||||||
admin?
|
|
||||||
end
|
|
||||||
|
|
||||||
def index?
|
def index?
|
||||||
everyone
|
everyone
|
||||||
end
|
end
|
||||||
|
@ -14,11 +14,7 @@ Rails.application.routes.draw do
|
|||||||
post :set_thank_you_note
|
post :set_thank_you_note
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
resources :comments, except: [:destroy] do
|
resources :comments
|
||||||
collection do
|
|
||||||
delete :destroy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
get '/my_request_for_comments', as: 'my_request_for_comments', to: 'request_for_comments#get_my_comment_requests'
|
get '/my_request_for_comments', as: 'my_request_for_comments', to: 'request_for_comments#get_my_comment_requests'
|
||||||
get '/my_rfc_activity', as: 'my_rfc_activity', to: 'request_for_comments#get_rfcs_with_my_comments'
|
get '/my_rfc_activity', as: 'my_rfc_activity', to: 'request_for_comments#get_rfcs_with_my_comments'
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user