2011-06-30 65 views
0

我想让ajaxful_rating与我的rails安装一起工作。Rails Gem:Ajaxful_rating路由问题

我已经找到了所有东西,直到用户点击一个星标来评分。

当我点击一个明星,浏览器URL指向http://localhost:3000/entries/1/rate?dimension=design&show_user_rating=false&small=true&stars=4 和我得到这个错误:No route matches "/entries/1/rate"

但我的路说:

resources :entries do 
    collection do 
     ... 
    end 
    member do 
     post 'rate' 
     put 'submit' 
    end 

有我丢失的东西?有些js不包括在内?我现在包括的所有内容都是jquery。

编辑

try { 
Element.update("ajaxful_rating_design_no-small_entry_1", "<ul class=\"ajaxful-rating\"><li class=\"show-value\" style=\"width: 60.0%\">Global rating average: 3.0 out of 5</li><li><a href=\"/entries/1/rate?dimension=design&amp;show_user_rating=false&amp;small=false&amp;stars=1\" class=\"stars-1\" data-method=\"post\" data-remote=\"true\" rel=\"nofollow\" title=\"Rate 1 out of 5\">1</a></li><li><a href=\"/entries/1/rate?dimension=design&amp;show_user_rating=false&amp;small=false&amp;stars=2\" class=\"stars-2\" data-method=\"post\" data-remote=\"true\" rel=\"nofollow\" title=\"Rate 2 out of 5\">2</a></li><li><a href=\"/entries/1/rate?dimension=design&amp;show_user_rating=false&amp;small=false&amp;stars=3\" class=\"stars-3\" data-method=\"post\" data-remote=\"true\" rel=\"nofollow\" title=\"Rate 3 out of 5\">3</a></li><li><a href=\"/entries/1/rate?dimension=design&amp;show_user_rating=false&amp;small=false&amp;stars=4\" class=\"stars-4\" data-method=\"post\" data-remote=\"true\" rel=\"nofollow\" title=\"Rate 4 out of 5\">4</a></li><li><a href=\"/entries/1/rate?dimension=design&amp;show_user_rating=false&amp;small=false&amp;stars=5\" class=\"stars-5\" data-method=\"post\" data-remote=\"true\" rel=\"nofollow\" title=\"Rate 5 out of 5\">5</a></li></ul>"); 
new Effect.Highlight("ajaxful_rating_design_no-small_entry_1",{}); 
} catch (e) { alert('RJS error:\n\n' + e.toString()); alert('Element.update(\"ajaxful_rating_design_no-small_entry_1\", \"<ul class=\\\"ajaxful-rating\\\"><li class=\\\"show-value\\\" style=\\\"width: 60.0%\\\">Global rating average: 3.0 out of 5</li><li><a href=\\\"/entries/1/rate?dimension=design&amp;show_user_rating=false&amp;small=false&amp;stars=1\\\" class=\\\"stars-1\\\" data-method=\\\"post\\\" data-remote=\\\"true\\\" rel=\\\"nofollow\\\" title=\\\"Rate 1 out of 5\\\">1</a></li><li><a href=\\\"/entries/1/rate?dimension=design&amp;show_user_rating=false&amp;small=false&amp;stars=2\\\" class=\\\"stars-2\\\" data-method=\\\"post\\\" data-remote=\\\"true\\\" rel=\\\"nofollow\\\" title=\\\"Rate 2 out of 5\\\">2</a></li><li><a href=\\\"/entries/1/rate?dimension=design&amp;show_user_rating=false&amp;small=false&amp;stars=3\\\" class=\\\"stars-3\\\" data-method=\\\"post\\\" data-remote=\\\"true\\\" rel=\\\"nofollow\\\" title=\\\"Rate 3 out of 5\\\">3</a></li><li><a href=\\\"/entries/1/rate?dimension=design&amp;show_user_rating=false&amp;small=false&amp;stars=4\\\" class=\\\"stars-4\\\" data-method=\\\"post\\\" data-remote=\\\"true\\\" rel=\\\"nofollow\\\" title=\\\"Rate 4 out of 5\\\">4</a></li><li><a href=\\\"/entries/1/rate?dimension=design&amp;show_user_rating=false&amp;small=false&amp;stars=5\\\" class=\\\"stars-5\\\" data-method=\\\"post\\\" data-remote=\\\"true\\\" rel=\\\"nofollow\\\" title=\\\"Rate 5 out of 5\\\">5</a></li></ul>\");\nnew Effect.Highlight(\"ajaxful_rating_design_no-small_entry_1\",{});'); throw e } 

这是当我点击了评级什么我的服务器说。

+0

将'post'改为'get'后,我在浏览器中看到了一个js ajax调用,现在有什么问题? –

+0

发布服务器日志 – Luke

+0

日志为空,但这是我点击某个星号时浏览器所说的内容。 –

回答

0

您的应用程序发送GET请求(参数在URL中传递),但您声明了POST路由。

post 'rate'更改为get 'rate'将允许此请求通过。

另一种可能性是,当应用程序生成POST时,您的应用程序在客户端生成GET。我需要看看你的视图代码来诊断那个。