在我的config/routes.rb中我有:簡單的Rails 3路由失敗 - 無路由匹配
post "portal_plan_document/update"
耙路線證實了這一點:
$ rake routes
portal_plan_document_update POST /portal_plan_document/update(.:format) {:controller=>"portal_plan_document", :action=>"update"}
....
在我的代碼有:
<%= form_for @plan_doc,
:url => portal_plan_document_update_path,
:method => "POST", :remote => true do |f| %>
在我的日誌文件我看到:
Started POST "/portal_plan_document/update" for 127.0.0.1 at 2011-03-31 18:04:37 -0400
ActionController::RoutingError (No route matches "/portal_plan_document/update"):
我迷失在這裏做什麼。任何幫助將不勝感激!
我應該說我正在使用Ruby 1.9.2和Rails 3.0.5。哦,我在更新routes.rb後重新啓動了服務器(WebBrick w/rails服務器)。
傑里米
我發現,如果我改變:方法=>「POST」到:方法=>「PUT」,改變我的路線關鍵字「發佈」以「放」,所有的作品都很棒。如上所述,將它們更改回「發佈」會導致全部失敗。那麼,把作品,發佈失敗!? – jeremy 2011-04-01 02:29:17
今天我在代碼中發現了同樣的問題。把作品,發佈失敗。 – YenTheFirst 2011-04-06 18:04:18
大多數瀏覽器都不支持除GET和POST請求以外的任何其他功能,因此Rails在POST中使用隱藏字段僞造PUT和DELETE。請參閱Yen的解答。 – Andrew 2011-08-12 16:51:02