So, I want voices to be launched using jQuery / AJAX and image. that is, I have an icon and thumbs down.
I installed the gem and ran rake db: migrate and took it apart.
But I'm not sure how to vote in my application.
In my model, I use one model for acts_as_voter, which is my model Client. The model that acts_as_votableis my model Upload. Thus, the client votes for the download. This is literally a big thumbs_up, not so much a โvoiceโ as such, because there is no karma or anything else. These are just thumbs up / down from each client per download.
In my opinion, thatโs how I would like to vote:
$("div#upvote img").live("click", compv.comments.upvote);
How can I use this to actually implement an action upvoteusing this Rails 3 stone?
Edit: If you are interested in knowing what the function does compv.comments.upvotein the 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 know well that this is likely to change if I want this gem to work correctly. It was only my version, trying to do what this gemstone can do (although, I would prefer an implementation out of this gem).