Simplify rendering flag actions

The `respond_with` method is no longer part of Rails (it's now part of
the responders gem) and we barely use it. Using a template forced us to
use different criteria for different controllers.

This change will also make it easier to fix the flag/unflag actions for
legislation proposals. With the old code, we would have to add another
condition for the legislation/proposals controller.
This commit is contained in:
Javi Martín
2020-03-20 16:11:29 +01:00
parent 91da038b27
commit 0d7c2c7a7c
2 changed files with 6 additions and 12 deletions

View File

@@ -35,13 +35,15 @@ class CommentsController < ApplicationController
def flag
Flag.flag(current_user, @comment)
set_comment_flags(@comment)
respond_with @comment, template: "comments/_refresh_flag_actions"
render "comments/_refresh_flag_actions"
end
def unflag
Flag.unflag(current_user, @comment)
set_comment_flags(@comment)
respond_with @comment, template: "comments/_refresh_flag_actions"
render "comments/_refresh_flag_actions"
end
private