【问题标题】:Destroy action in a Rails 3.0 app with jquery mobile is producing a routing error使用 jquery mobile 在 Rails 3.0 应用程序中销毁操作会产生路由错误
【发布时间】:2012-03-16 09:30:27
【问题描述】:

我在 rails 3.0 应用程序中使用 jquery mobile。尝试从用户列表中删除项目时出现路由错误。代码和错误信息如下。

index.mobile.erb:

<% @items.each do |i| %>
   ...
   <div data-role="button">
      <%= link_to 'Delete', i, :confirm => 'Are you sure?', :method => :delete %>
   </div>
<% end %>

路由文件:

resources :items, :except => [:show]

耙路线:

DELETE /items/:id(.:format)            {:action=>"destroy", :controller=>"items"}

错误信息:

Started GET "/items/2" for 127.0.0.1 at 2012-02-26 13:31:37 -0500
ActionController::RoutingError (No route matches "/items/2"):

我错过了什么?

谢谢!

更新 - 萤火虫: @http://localhost:3000/javascripts/jquery-1.6.1.js?1310343332:641 @http://localhost:3000/javascripts/jquery.mobile-1.0.1.js?1329380575:2737 @http:// /localhost:3000/javascripts/jquery.mobile-1.0.1.js?1329380575:3030 @http://localhost:3000/javascripts/jquery.mobile-1.0.1.js?1329380575:3393 @http://localhost :3000/javascripts/jquery-1.6.1.js?1310343332:2926 @http://localhost:3000/javascripts/jquery-1.6.1.js?1310343332:2560 jquery...0343332(第 641 行) "NetworkError: 404 Not Found - http://localhost:3000/items/2"

【问题讨论】:

    标签: ruby-on-rails-3 jquery-mobile


    【解决方案1】:

    您遇到的问题似乎与@@Rails' link_to method: GETing when it should DELETE 提到的相同。

    您能否粘贴其余的请求参数(chrome 开发者控制台或 firebug)?必须看看 rails 是否正在尝试变魔术来适应 HTTP 删除动词。

    【讨论】:

    • Firebug 输出现在位于问题的底部。谢谢。
    猜你喜欢
    • 1970-01-01
    • 2012-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多