Skip to content

Instantly share code, notes, and snippets.

@jmarsh24
Created March 1, 2022 16:38
Show Gist options
  • Save jmarsh24/175f68dc7d8e0828e68f6753acb61f9e to your computer and use it in GitHub Desktop.
Save jmarsh24/175f68dc7d8e0828e68f6753acb61f9e to your computer and use it in GitHub Desktop.
<%= render "videos/show/like_count", video: @video %>
<%= render "videos/show/downvote_link", video: @video %>
<%= render "videos/show/upvote_link", video: @video %>
<div class="like-buttons">
<%= turbo_frame_tag "#{dom_id(@video)}_vote" do %>
<%= render 'videos/show/vote', video: @video %>
<% end %>
</div>
def upvote
@video = Video.find(params[:id])
if current_user.voted_up_on? @video
@video.unvote_by current_user
else
@video.upvote_by current_user
end
render "videos/show/vote"
end
def downvote
@video = Video.find(params[:id])
if current_user.voted_down_on? @video
@video.unvote_by current_user
else
@video.downvote_by current_user
end
render "videos/show/vote"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment