我不知道是什麼原因,我的應用沒有響應任何POST請求,這是一個非REST的URL。路由不工作
下面是我的routes.rb文件。
constraints(Subdomain) do
resources :invitations
resources :settings, :only => [:index, :create, :destroy]
scope "/settings" do
get "/departments" => "settings#departments"
get "/job_types" => "settings#job_types"
get "/industries" => "settings#industries"
get "/functional_areas" => "settings#functional_areas"
get "/managers" => "settings#managers"
get "/hrs_responsible" => "settings#hrs_responsible"
get "/welcome_text" => "settings#welcome_text"
post "/save_welcome_text" => "settings#save_welcome_text" <-------
end
end
我認爲文件中,我有
=form_for(@setting), :url => "/settings/save_welcome_text", :method => :post do |f|
- All the form fields here.
- f.submit "Save"
這個要點包含生成的HTML,以及相應的服務器日誌。 https://gist.github.com/943984
當我點擊提交時,我看到「路由錯誤」,沒有這樣的路由存在。從服務器日誌中,我可以嗅探到請求是作爲POST請求發送的。 但是,如果我將它從routes.rb文件中的「post」更改爲「匹配」,則可以使用。所有GET請求都正常工作。 我錯過了什麼嗎?
你覺得爲什麼不工作呢?顯示你如何試圖稱呼它。顯示你的鏈接 – fl00r 2011-04-27 08:57:03
那麼,我有一個「form_for(@setting),:url =>」/ settings/save_welcome_text「,:method =>:post」,它會拋出一個錯誤,表示沒有路由存在。 – Deepak 2011-04-27 09:07:57
看看源代碼並告訴我「