comments: allow swapping votes.
Allow users to upvote a comment, then downvote it, without raising an error or having to manually remove the upvote first. The upvote is automatically removed and replaced by the downvote. Changes to the /comment_votes API: * `POST /comment_votes` and `DELETE /comment_votes` now return a comment vote instead of a comment. * The `score` param in `POST /comment_votes` is now 1 or -1, not `up` or `down.`
This commit is contained in:
@@ -51,7 +51,7 @@
|
||||
<% elsif upvoted? %>
|
||||
<%= link_to "🡹", comment_comment_votes_path(comment_id: comment.id), class: "comment-upvote-link comment-unvote-link", method: :delete, remote: true %>
|
||||
<% else %>
|
||||
<%= link_to "🡹", comment_comment_votes_path(comment_id: comment.id, score: "up"), class: "comment-upvote-link", method: :post, remote: true %>
|
||||
<%= link_to "🡹", comment_comment_votes_path(comment_id: comment.id, score: "1"), class: "comment-upvote-link", method: :post, remote: true %>
|
||||
<% end %>
|
||||
|
||||
<span class="comment-score"><%= comment.score %></span>
|
||||
@@ -61,7 +61,7 @@
|
||||
<% elsif downvoted? %>
|
||||
<%= link_to "🡻", comment_comment_votes_path(comment_id: comment.id), class: "comment-downvote-link comment-unvote-link", method: :delete, remote: true %>
|
||||
<% else %>
|
||||
<%= link_to "🡻", comment_comment_votes_path(comment_id: comment.id, score: "down"), class: "comment-downvote-link", method: :post, remote: true %>
|
||||
<%= link_to "🡻", comment_comment_votes_path(comment_id: comment.id, score: "-1"), class: "comment-downvote-link", method: :post, remote: true %>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user