Rails路由资源:地址 - Singular&复数

时间:2014-05-08 03:47:50

标签: ruby-on-rails ruby-on-rails-3 routes

我有一条地址路线:

  namespace :carts do
    resources :address

然而,它会为新路径addres生成拼写错误。这是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 个答案:

答案 0 :(得分:2)

您必须根据您的控制器名称命名您的路线。并且它们都必须是复数形式

因此,正确的地址路由是:resources :addresses,知道您的控制器必须是AddressesController

有关路由的更多信息:http://guides.rubyonrails.org/routing.html