我想用宝石“Thumbs_up”为我的应用程序 RoR 添加投票,但是当我点击“vote_up”或“vote_down”时,什么也没有发生,我不知道我在 viex 中的问题是:
= javascript_include_tag 'votecount'
= t "idea.colaboration.accept.what_do_you_want_html", user: @collab.user.name
.buttons[style="float:right"]
button[type="submit"]
= link_to image_tag('thumb_up.png'), vote_up_idea_path(@idea), data: {vote: "up"}, remote: true,:method => :post
button[type="submit"]
= link_to image_tag('thumb_down.png'), vote_down_idea_path(@idea), data: {vote: "down"}, remote: true,:method => :post
在“votecount.js”中,我有:
$(function(){
$(".ratelink").click(function(){
var val = $(this).attr('updown');
var theid = $(this).attr('theid');
$("#votewrapper").block({ //blocks rate-rates while processing
message: null,
overlayCSS: {
backgroundColor: '#FFF',
opacity: 0.6,
cursor: 'default'
},
});
if (val == "up") {
$.ajax({
type: 'PUT',
url: "/idea/vote_up?id="+theid,
success: function(){
$("#votewrapper").unblock();
}
});
} else {
$.ajax({
type: 'PUT',
url: "/idea/vote_down?id="+theid,
success: function(){
$("#votewrapper").unblock();
}
});
}
})
(每个用户都可以为一个想法投票,非常感谢