我有以下途徑:軌道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
創建行動:
# POST /halls
def create
@hall = Hall.new(hall_params)
if @hall.save
redirect_to @hall, notice: 'Hall was successfully created.'
else
render action: 'new'
end
end
但現在我得到以下錯誤的:
undefined method `halls_path' for #<#<Class:0xb0c7300>:0xab9e7c0>
有沒有辦法使這個render action: 'new'
部分工作與重定向回形成驗證和錯誤消息?
耙路線
venue_halls_path GET /venues/:venue_id/halls(.:format) halls#index
POST /venues/:venue_id/halls(.:format) halls#create
new_venue_hall_path GET /venues/:venue_id/halls/new(.:format) halls#new
edit_hall_path GET /halls/:id/edit(.:format) halls#edit
hall_path GET /halls/:id(.:format) halls#show
PATCH /halls/:id(.:format) halls#update
PUT /halls/:id(.:format) halls#update
DELETE /halls/:id(.:format) halls#destroy
你嘗試''耙路線| grep halls''看看它是怎麼回事? –
我剛剛更新了我的回答 –
您在過去7天中詢問了11條ruby-on-rails問題 - 請在提問前閱讀官方文檔 – emaillenin