本文介绍了使用资源的Rails路线:地址-单数&复数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一条地址路由:
namespace :carts do
resources :address
但是,它为新路径 addres
生成了一个拼写错误。这是Rails 3.2.14中的错误吗?
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
推荐答案
您必须根据控制器的名称来命名路由。而且它们都必须是复数形式
you must name your route according to your controller's name. And both of them must be plural form
所以地址的正确路由是: resources:addresses
,知道您的控制器必须是 AddressesController
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
这篇关于使用资源的Rails路线:地址-单数&复数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!