0
我有淺路線如下圖所示:軌道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#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)
但是這並不總是可行的,尤其是當它達到index
行動,因爲它不會設置@booth
資源。
是否有解決此問題的好方法?
會你把這個置於索引操作之下?我剛剛在'@booths = Booth.all'後面試過,但找不到'@ hall'變量。 ''sidebar_menu'函數裏面有幫助器''after_action:sidebar_menu'我認爲'@hall = Hall.find(params [:hall_id])'在'index'動作中被設置,它會設置'@hall '首先我可以在幫手中使用這個,但是我得到'nil' –
@PassionateDeveloper我想你應該在'before_filter'中設置'@ hall'。 –
現在都在工作。謝謝!!! –