Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 对于';什么是嵌套的?_Ruby On Rails_Ruby On Rails 3_Routing_Ruby On Rails 3.1 - Fatal编程技术网

Ruby on rails 对于';什么是嵌套的?

Ruby on rails 对于';什么是嵌套的?,ruby-on-rails,ruby-on-rails-3,routing,ruby-on-rails-3.1,Ruby On Rails,Ruby On Rails 3,Routing,Ruby On Rails 3.1,当我在我的routes.rb中有resources:feedback时,我会使用这个链接助手,它可以很好地工作: <%= link_to 'Delete', feedback, :confirm => 'Are you sure?', :method => :destroy %> 我得到这个错误: ActionView::Template::Error (No route matches {:action=>"show", :controller=>"fee

当我在我的
routes.rb
中有
resources:feedback
时,我会使用这个链接助手,它可以很好地工作:

<%= link_to 'Delete', feedback, :confirm => 'Are you sure?', :method => :destroy %>
我得到这个错误:

ActionView::Template::Error (No route matches {:action=>"show", :controller=>"feedbacks", :username=>#<Feedback id: 1, poster_id: 1, receiver_id: 2, content: "Test 2 is awesome", created_at: "2011-09-10 23:00:32", updated_at: "2011-09-10 23:00:32">}):
ActionView::Template::Error(没有路由匹配{:action=>“show”,:controller=>“feedbacks”,:username=>#}):
如何使用Rails助手方法创建指向该嵌套资源的链接,指向
Delete/Destroy


谢谢。

在您的情况下,您始终可以运行rake routes来查看路由系统生成的内容:

feedbacks GET    /:username/feedbacks(.:format) {:action=>"index", :controller=>"feedbacks"}
feedback DELETE /:username/feedbacks/:id(.:format) ....

在您的情况下,您始终可以运行rake routes以查看路由系统生成的内容:

feedbacks GET    /:username/feedbacks(.:format) {:action=>"index", :controller=>"feedbacks"}
feedback DELETE /:username/feedbacks/:id(.:format) ....

我的坏…
反馈\u用户\u url
不起作用。我第一次在这个问题上就错了。已添加正确的代码段。有效的方法是
反馈
。但这并没有给我找到正确资源的正确途径。如何为delete方法获取正确的资源?当我执行
feedback\u user\u url
时,我会遇到以下错误:
未定义的方法“feedback\u user\u url”for#
不起作用。当我删除时,我在我的日志中看到:
Started POST”/test/feedbacks/1“for 127.0.0.1,2011-09-12 16:42:21-0500 ActionController::RoutingError(没有路由匹配[POST]“/test/feedbacks/1”):
并且对象没有被删除。事实上,我得到了它。我不得不将
:method
:destroy
更改为
:delete
。支持的动词的链接是:post、:delete和:put。没有销毁)我的坏…
反馈\u用户\u url
不起作用。我第一次在这个问题上就错了。已添加正确的代码段。有效的方法是
反馈
。但这并没有给我找到正确资源的正确途径。如何为delete方法获取正确的资源?当我执行
feedback\u user\u url
时,我会遇到以下错误:
未定义的方法“feedback\u user\u url”for#
不起作用。当我删除时,我在我的日志中看到:
Started POST”/test/feedbacks/1“for 127.0.0.1,2011-09-12 16:42:21-0500 ActionController::RoutingError(没有路由匹配[POST]“/test/feedbacks/1”):
并且对象没有被删除。事实上,我得到了它。我不得不将
:method
:destroy
更改为
:delete
。支持的动词的链接是:post、:delete和:put。(没有破坏)
feedback_url('username', feedback.id)
= link_to 'Delete', feedback_url(user.name, feedback.id), :method => :delete