Rails route with resources :address - Singular & Plural

。_饼干妹妹 提交于 2019-12-23 05:22:46

问题


I have a route for addresses:

  namespace :carts do
    resources :address

Yet it generates a mispelling for the new path, addres. Is this a bug in Rails 3.2.14?

              carts_address GET    /carts/address(.:format)                                             refinery/carts/address#index
                            POST   /carts/address(.:format)                                             refinery/carts/address#create
           new_carts_addres GET    /carts/address/new(.:format)                                         refinery/carts/address#new
          edit_carts_addres GET    /carts/address/:id/edit(.:format)                                    refinery/carts/address#edit
               carts_addres GET    /carts/address/:id(.:format)                                         refinery/carts/address#show

回答1:


you must name your route according to your controller's name. And both of them must be plural form

So the correct route for addresses is: resources :addresses, knowing that your controller must be AddressesController

More info on routing: http://guides.rubyonrails.org/routing.html



来源:https://stackoverflow.com/questions/23532388/rails-route-with-resources-address-singular-plural

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!