Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/53.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_Routes_Ruby On Rails 3.2 - Fatal编程技术网

Ruby on rails 具有嵌套获取中断资源路由的资源路由?

Ruby on rails 具有嵌套获取中断资源路由的资源路由?,ruby-on-rails,routes,ruby-on-rails-3.2,Ruby On Rails,Routes,Ruby On Rails 3.2,运行Rails3.2.11,我有一个常规的控制器“LbuController”,它基本上是一个增强的脚手架,通过用于AJAX请求的4个附加GET方法进行了增强 resources :lbus do get 'add_offering' get 'remove_offering' get 'add_offering_element' get 'remove_offering_element' end 运行rake routes会提供以下路由 lbu_add_

运行Rails3.2.11,我有一个常规的控制器“LbuController”,它基本上是一个增强的脚手架,通过用于AJAX请求的4个附加GET方法进行了增强

resources :lbus do
  get 'add_offering'
  get 'remove_offering'
  get 'add_offering_element'
  get 'remove_offering_element'
end
运行
rake routes
会提供以下路由

           lbu_add_offering GET    /lbus/:lbu_id/add_offering(.:format)                                 lbus#add_offering
        lbu_remove_offering GET    /lbus/:lbu_id/remove_offering(.:format)                              lbus#remove_offering
   lbu_add_offering_element GET    /lbus/:lbu_id/add_offering_element(.:format)                         lbus#add_offering_element
lbu_remove_offering_element GET    /lbus/:lbu_id/remove_offering_element(.:format)                      lbus#remove_offering_element
                       lbus GET    /lbus(.:format)                                                      lbus#index
                            POST   /lbus(.:format)                                                      lbus#create
                    new_lbu GET    /lbus/new(.:format)                                                  lbus#new
                   edit_lbu GET    /lbus/:id/edit(.:format)                                             lbus#edit
                        lbu GET    /lbus/:id(.:format)                                                  lbus#show
                            PUT    /lbus/:id(.:format)                                                  lbus#update
                            DELETE /lbus/:id(.:format)                                                  lbus#destroy
这似乎正是我想要的

但是在链接到
http://localhost:3000/lbus/new
创建时使用
链接到“new”,new\u lbu\u路径
会出现以下错误:

No route matches {:action=>"add_offering", :lbu_id=>nil, :offering_id=>1, :controller=>"lbus"}
这对我来说毫无意义。 有人知道这里发生了什么,出了什么问题吗


提前谢谢

在“新建”视图中,您必须使用lbu添加提供路径


这条路似乎不正确。错误是指:action=>“add_offering”。

我认为错误与新操作无关。但它指的是添加产品->单击“新建”后,新建的控制器操作或重定向到的视图中是否有错误?@Oliver在“新建”视图中,您必须使用lbu添加产品路径。这条路似乎不正确。错误是指:action=>“add_offering”否,它必须是与路由相关的问题。只要我用
get
方法删除块,
new
操作就会按预期工作。@Nishant-你是对的。就是这样!感谢you@Oliver很乐意帮忙。我已将其转化为一个答案——你可以接受。