0

我很努力地獲得正確的URL給form_for更新操作以處理單數資源。Rails:奇異資源更新路徑問題

我的routes.rb情況如下:

scope "(:locale)", :locale => /en|fr/ do 
    namespace :quickwizard, :module => 'quick_wizard' do 
    resource :business, controller: 'business' 
    end 
end 

這給了以下路線:

 quickwizard_business POST (/:locale)/quickwizard/business(.:format)   quick_wizard/business#create {:locale=>/en|fr/} 
new_quickwizard_business GET (/:locale)/quickwizard/business/new(.:format)  quick_wizard/business#new {:locale=>/en|fr/} 
edit_quickwizard_business GET (/:locale)/quickwizard/business/edit(.:format)  quick_wizard/business#edit {:locale=>/en|fr/} 
          GET (/:locale)/quickwizard/business(.:format)   quick_wizard/business#show {:locale=>/en|fr/} 
          PUT (/:locale)/quickwizard/business(.:format)   quick_wizard/business#update {:locale=>/en|fr/} 
          DELETE (/:locale)/quickwizard/business(.:format)   quick_wizard/business#destroy {:locale=>/en|fr/} 

,並在視圖:

= simple_form_for @business, url: quickwizard_business_path(@business), validate: true do |f| 

生成更新不正確的URL (但適用於創作):

<form accept-charset="UTF-8" action="/15/quickwizard/business" ... 

如果我把正確的路線改爲手動,它適用於更新:

= simple_form_for @business, url:"/quickwizard/business", html: { method: 'put' }, validate: true do |f| 

所以我的問題是:什麼是做到這一點,所以我把無論是創建和更新操作的作品網址的正確方法?

回答

0

問題出現在語言環境中,而不是單數資源中。嘗試生成的網址與

quickwizard_business_path(@business, locale: nil) 
+0

不解決它。我更新了routes.rb以包含範圍(沒有想到發佈它)。鑑於我指定了區域設置的可能選項,那麼如何將商業標識誤認爲某個區域? –