Rails3 路由错误。 :方法=> :delete, 这将是“没有路由匹配”

发布于 2024-10-29 01:04:49 字数 1242 浏览 0 评论 0原文

我想发起破坏行动。它已经在控制器中定义了。 我想要销毁的模型是嵌套资源。但路由存在于rake paths结果中。

  new_content_model GET    /contents/:content_id/model/new(.:format)                         {:controller=>"models", :action=>"new"}
 edit_content_model GET    /contents/:content_id/model/:id/edit(.:format)                    {:controller=>"models", :action=>"edit"}
      content_model PUT    /contents/:content_id/model/:id(.:format)                         {:controller=>"models", :action=>"update"}
                    DELETE /contents/:content_id/model/:id(.:format)                         {:controller=>"models", :action=>"destroy"}

我从这个 url 调用 destroy 操作,

<%= link_to "destroy nested model", content_model_path( @content.id, @model.id ), :confirm => "are you sure?", :method => :delete %>

它没有路由匹配。

Routing Error
No route matches "/contents/1/model/1"`

请告诉我一些解决方案。


已经在layouts/application.html.erb中写入<%= javascript_include_tag :all %>

Rails 3 link_to (:method => :delete) 不工作

I want to call a destroy action. It is already define in controller.
The model that I want to destroy is nested resource. But route is existing in rake routes result.

  new_content_model GET    /contents/:content_id/model/new(.:format)                         {:controller=>"models", :action=>"new"}
 edit_content_model GET    /contents/:content_id/model/:id/edit(.:format)                    {:controller=>"models", :action=>"edit"}
      content_model PUT    /contents/:content_id/model/:id(.:format)                         {:controller=>"models", :action=>"update"}
                    DELETE /contents/:content_id/model/:id(.:format)                         {:controller=>"models", :action=>"destroy"}

And I call destroy action from this url

<%= link_to "destroy nested model", content_model_path( @content.id, @model.id ), :confirm => "are you sure?", :method => :delete %>

It is no route matches.

Routing Error
No route matches "/contents/1/model/1"`

Please tell me some solutions.


Already wrote <%= javascript_include_tag :all %> in layouts/application.html.erb

Rails 3 link_to (:method => :delete) not working

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

何以心动 2024-11-05 01:04:49

我解决了这个问题。
我删除了 rails.jsprototype.js 是错误的。

感谢您的出席。抱歉,缺乏信息。

I solved this problem.
It was wrong that I deleted rails.js and prototype.js.

Thank you for your attending. Sorry for lack of information.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文