开发者

Rails 3 app will not match a route even though rake routes shows it

开发者 https://www.devze.com 2023-02-04 06:07 出处:网络
Here is a portion of my routes file: resource :vendor do post \'modify_account\' end Running rake routes will generate the following line

Here is a portion of my routes file:

resource :vendor do post 'modify_account' end

Running rake routes will generate the following line

           modify_account_vendor POST   /vendor/modify_account(.:format)                               {:action=>"modify_account", :controller=>"vendors"}
                          vendor POST   /vendor(.:format)                                              {:action=>"create", :controller=>"vendors"}
                      new_vendor GET    /vendor/new(.:format)                                          {:action=>"new", :controller=>"vendors"}
                     edit_vendor GET    /vendor/edit(.:format)                                         {:action=>"edit", :controller=>"vendors"}
                                 GET    /vendor(.:format)               开发者_运维问答                               {:action=>"show", :controller=>"vendors"}
                                 PUT    /vendor(.:format)                                              {:action=>"update", :controller=>"vendors"}
                                 DELETE /vendor(.:format)                                              {:action=>"destroy", :controller=>"vendors"}
                                        /vendor(.:format)                                              {:action=>"account", :controller=>"vendors"}

I can load the form and verify the URL is correct in the form's action, but when I submit, the app throws an error:

No route matches "/vendor/modify_account"

Any suggestions as to what I can do to troubleshoot? Firebug verifies that the error page is of type POST.


I had a simular issue with a singleton resource, check that you are passing in the url to the form_tag, we use simple_form and have the following

<%= simple_form_for @enterprise_account, :url => enterprise_account_path do |f| -%>


As it turns out, I believe the issue was with my choice of "action verb" - I should have been using PUT instead of POST. This is my new routes file, and the only thing I had to change was the _url helper method names.

resource :vendor do put 'account', :action => 'modify_account' end
0

精彩评论

暂无评论...
验证码 换一张
取 消