comment votes: fix error handling.
Return the comment itself and a standard error response on failure.
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
<% if @error %>
|
||||
Danbooru.error("<%= j @error.to_s %>");
|
||||
<% elsif @comment_vote.errors.any? %>
|
||||
Danbooru.error("<%= j @comment_vote.errors.full_messages.join('; ') %>");
|
||||
<% elsif @comment_vote.is_negative? %>
|
||||
<% if @comment_vote.is_negative? %>
|
||||
$(".comment[data-comment-id=<%= @comment.id %>]").remove();
|
||||
<% end %>
|
||||
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
<% if @error %>
|
||||
{"success": false, "errors": <%= @error.to_s.to_json.html_safe %>}
|
||||
<% elsif @comment_vote.errors.any? %>
|
||||
{"success": false, "errors": <%= @comment_vote.errors.full_messages.to_json.html_safe %>}
|
||||
<% else %>
|
||||
{"success": true}
|
||||
<% end %>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<% if @comment_vote.errors.any? %>
|
||||
<response success="false"><%= @comment_vote.errors.full_messages.to_json.html_safe %></response>
|
||||
<% else %>
|
||||
<response success="true"/>
|
||||
<% end %>
|
||||
@@ -1,7 +1,3 @@
|
||||
<% if @error %>
|
||||
Danbooru.error("<%= j @error.to_s %>");
|
||||
<% else %>
|
||||
$("#comment-vote-up-link-for-<%= @comment.id %>").show();
|
||||
$("#comment-vote-down-link-for-<%= @comment.id %>").show();
|
||||
$("#comment-unvote-link-for-<%= @comment.id %>").hide();
|
||||
<% end %>
|
||||
$("#comment-vote-up-link-for-<%= @comment.id %>").show();
|
||||
$("#comment-vote-down-link-for-<%= @comment.id %>").show();
|
||||
$("#comment-unvote-link-for-<%= @comment.id %>").hide();
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
<% if @error %>
|
||||
{"success": false, "reason": <%= @error.to_s.to_json.html_safe %>}
|
||||
<% else %>
|
||||
{"success": true}
|
||||
<% end %>
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<% if @error %>
|
||||
<response success="false"><%= @error.to_s %></response>
|
||||
<% else %>
|
||||
<response success="true"/>
|
||||
<% end %>
|
||||
Reference in New Issue
Block a user