问题
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