Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/59.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.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 Rails 4浅路由菜单参数未定义错误_Ruby On Rails_Ruby_Ruby On Rails 4 - Fatal编程技术网

Ruby on rails Rails 4浅路由菜单参数未定义错误

Ruby on rails Rails 4浅路由菜单参数未定义错误,ruby-on-rails,ruby,ruby-on-rails-4,Ruby On Rails,Ruby,Ruby On Rails 4,我有如下浅路线: resources :venues, shallow: true do #Halls get "hall/:id/exhibition" => "halls#exhibition", as: :exhibition get "hall/:id/visit" => "halls#visit", as: :hall_visit get "structure", :to => "venues#v

我有如下浅路线:

    resources :venues, shallow: true do
        #Halls
        get "hall/:id/exhibition" => "halls#exhibition", as: :exhibition
        get "hall/:id/visit" => "halls#visit", as: :hall_visit
        get "structure", :to => "venues#venue_structure"
        resources :asset_types, :booths_tags, :tags, :uploaded_files, :events, :chats
        resources :halls do
            resources :webcasts
            resources :booths do
                resources :chats
            end
        end
    end
下面的帮助程序存在问题,我需要提供
@booth
资源作为参数:

hall_booths_path(@booth.hall)
但这并不总是可能的,尤其是当它进入
索引
操作时,因为它没有设置
@booth
资源


有没有解决此问题的好方法?

即使您在
展位#索引
操作中,您也有
大厅
id,因此您可以设置
@hall
实例变量:

@hall = Hall.find(params[:hall_id])
然后,您可以执行以下操作:

hall_booths_path(@hall)

你能把这个放在索引下吗?我刚刚在
@booths=Booth.all
之后尝试了这个,但是它找不到
@hall
变量。我在
侧边栏_菜单
函数中找到了助手,该函数在_操作:侧边栏_菜单后由
调用,我想
@hall=hall.find(params[:hall\u id])
索引中设置
它将首先设置
@hall
的操作,因此我可以在助手中使用它,但我得到了
nil
somehow@PassionateDeveloper我想你应该在过滤器之前的
中设置
@hall