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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user