Allow liking/unliking when JavaScript is disabled

Even if pretty much nobody uses a browser with JavaScript disabled when
navigating our sites, there might be times where JavaScript isn't loaded
for reasons like a slow internet connections not getting the JavaScript
files or a technical issue.

So we're making it possible to still use the like/unlike buttons in
these cases.
This commit is contained in:
Javi Martín
2023-10-11 14:11:27 +02:00
parent 38e81f2858
commit 7070b0915b
7 changed files with 81 additions and 1 deletions

View File

@@ -10,6 +10,7 @@ module Comments
@comment.vote_by(voter: current_user, vote: params[:value])
respond_to do |format|
format.html { redirect_to request.referer, notice: I18n.t("flash.actions.create.vote") }
format.js { render :show }
end
end
@@ -18,6 +19,7 @@ module Comments
@comment.unvote_by(current_user)
respond_to do |format|
format.html { redirect_to request.referer, notice: I18n.t("flash.actions.destroy.vote") }
format.js { render :show }
end
end