Vote_fu和Ajax请求

我现在已经好几个小时了,试着投票和投票。 我终于对一个可投票的对象(专辑)进行了投票,但是我必须不断更新页面以查看我对使用rails的Ajax知识的影响是基本的,我不知道我在哪里出错这个任何帮助都会太棒了会非常感激!!!

相关代码如下:

javascript文件

application.js: // Place your application-specific JavaScript functions and classes here // This file is automatically included by javascript_include_tag :defaults jQuery.ajaxSetup({ 'beforeSend': function(xhr) {xhr.setRequestHeader("Accept", "text/javascript")} }) jQuery(document).ready(function() { $("#votes_ .album").bind('click', function(e) }); 

| ___________________________________________________________________________________________

jquery.js jquery-ui.js jrails.js

Layout / appliction.html.erb(javascript添加到标题中)

   

查看/票

_album_vote.html.erb

   user_album_votes_path(album.user, album, :vote => :true, :format => :rjs), :method => :post %>  current_user.vote_down_path(album), :vote => :false, :format => :rjs, :url => user_album_votes_path(album.user, album, :vote => :false, :format => :rjs), :method => :post %>  Votes:  

| ___________________________________________________________________________________________

视图/专辑/显示:

 <div id="votes_" class="album_votes">  "votes/album_vote", :locals => {:album => @album} %> 

| ___________________________________________________________________________________________

create.rjs

 page.replace_html "votes_#{@album.id}", :partial => "album_vote", :locals => {:album => @album} 

| ___________________________________________________________________________________________

error.rjs

 page.alert "Couldn't save your vote: You can only vote once, and you cannot vote for your own items." 

| ___________________________________________________________________________________________

我已经尝试使用ID #votes_ .album,我认为它名称不正确,但它仍然无法正常工作甚至没有错误,就好像javascript已关闭!

任何帮助都会很棒!

在服务器控制台上发现错误:

 NameError (uninitialized constant Mime::RJS): app/controllers/votes_controller.rb:54:in `create' app/controllers/votes_controller.rb:52:in `create' 

我会在熄灯前(睡觉时间)同意这个!

如果你愿意帮助我!

问候

看起来你的基本jquery设置有问题。 以下两篇文章肯定帮助我完成了jQuery学习曲线:

jQuery Railscast

初学者公会到jQuery和Rails

这些post以及惊人的FireBug应该可以帮到你

希望这可以帮助。