Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4003516
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:09:43+00:00 2026-05-20T08:09:43+00:00

So I want votes to be triggered using jQuery/AJAX and an image. i.e. I

  • 0

So I want votes to be triggered using jQuery/AJAX and an image. i.e. I have a thumbs up icon and thumbs down.

I have setup the gem, and ran the rake db:migrate and have everything sorted out.

But I am not sure how to execute a vote in my app.

In my model, I am using one model to acts_as_voter, which is my Client model. The model that acts_as_votable is my Upload model. So a client votes up/down an upload. It literally is a thumbs_up, not so much a ‘vote’ per se, because there is no karma or anything. It is simply a thumbs up/down from each client per upload.

In my view, this is how I would like to execute the vote:

$("div#upvote img").live("click", compv.comments.upvote);

How do I use this actually implement an upvote action using this Rails 3 gem ?

Edit: If you are interested in seeing what the function compv.comments.upvote does in it’s current form, you can see it here:

    compv.comments.upvote = function(event){
    var uploaderID = compv.comments.getUploadID(event.target);
    $.ajax({
        url: '/uploads/'+uploaderID+'/upvote.js',
        success: function(data, status, xhr){
            var uploadElement = $("li[data-upload-id="+uploaderID+"]");
            uploadElement.attr('data-upload-upvote', parseInt(uploadElement.attr('data-upload-upvote'))+1);
            var imgElement = uploadElement.find("div.image-wrapper > img");
            var img_opacity = imgElement.css('opacity');
            if(img_opacity < 1 ) {  
                imgElement.fadeTo(600, 1, function() {
            }); 
            }
            imgElement.removeClass("downvoted");
            imgElement.addClass("upvoted");
        }
    });
};

However, I am well aware that this will likely have to change if I am to get this gem working right. That was just my version of trying to do what this gem can do (although, I would much prefer an implementation from this gem).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T08:09:44+00:00Added an answer on May 20, 2026 at 8:09 am

    This is more a question of how to build Ajax actions in Rails in general than anything to do with this particular gem.

    Referring to the setup here: Clarification on how to use "thumbs_up" voting gem with Rails 3

    You can set this up in jQuery with something like:

    $.post('/posts/' + id + '/vote_up', function() {
      alert('success');
    })
    .error(function() { alert('Vote error.'); });
    

    Hopefully that gets you closer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have @microposts = Micropost.order('votes desc').paginate(:page => params[:page]) and it works but I want
i want to implement a digg-like vote up/down method in my rails application using
I have votes in my system, but I want to sort by some calculation
My query is essentially the following: entries=Entry.all().order(-votes).order(-date).filter(votes >, VOTE_FILTER).fetch(PAGE_SIZE+1, page* PAGE_SIZE) I want to
want to know why String behaves like value type while using ==. String s1
want to have a Hyperlink-Button in a gridView in which I can display a
I am using SQL Server 2005. I have a site that people can vote
I have two rating/votes tables. One for user votes and stats and another for
I have an array of 'questions' ordered according to their number of votes, and
i've two columns in mysql db table votes : accept and reject i want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.