Created
November 12, 2012 02:39
-
-
Save joshsmith/4057212 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| = link_to(comment_create_comment_vote_path(@comment, :comment_vote => { :comment_id => @comment.id, :user_id => current_user.id, :vote_flag => true }), {:method => :post, :remote => true, :class => 'like-comment'}) do | |
| %i.icon-thumbs-up | |
| %span.helpful-text Mark helpful |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CommentVotesController < ApplicationController | |
| load_and_authorize_resource | |
| def create | |
| @vote = CommentVote.new(params[:comment_vote]) | |
| @vote.save | |
| respond_to do |format| | |
| format.html { redirect_to(@vote) } | |
| format.js { render :json => @vote, :status => :created, :location => @vote } | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $('.like-comment').on('ajax:success', function(event, xhr, data, status) { | |
| console.log(event, xhr, data, status); | |
| $(this).removeClass('like-comment').addClass('unlike-comment') | |
| .children('.helpful-text').text('You marked helpful'); | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment