1
我已經命名空間的控制器實體::客戶模塊路由用的form_for(@object)
class Entities::CustomersController < ApplicationController
...
end
和命名空間的ActiveRecord模型:
class Entities::Customer < Entities::User
end
在我的routes.rb文件我有:
resources :customers, module: :entities
該模塊:實體存在,因爲我不想有如下路線:
/實體/客戶但僅限於:
/客戶。
的問題,當我使我的形式開始:
<%= simple_form_for(@customer) do |f| %>
<%= f.input :email %>
<%= f.input :password %>
<%= f.input :name %>
<%= f.button :submit %>
<% end %>
這將引發錯誤:未定義的方法`entities_customer_path」類..
因此錯誤是軌認爲,正確的路徑是與前綴實體。
耙路線給我:
Prefix Verb URI Pattern Controller#Action
customers GET /customers(.:format) entities/customers#index
POST /customers(.:format) entities/customers#create
new_customer GET /customers/new(.:format) entities/customers#new
edit_customer GET /customers/:id/edit(.:format) entities/customers#edit
customer GET /customers/:id(.:format) entities/customers#show
PATCH /customers/:id(.:format) entities/customers#update
PUT /customers/:id(.:format) entities/customers#update
DELETE /customers/:id(.:format) entities/customers#destroy
爲客戶提供請你的路由 –
資源:客戶,模塊:實體如在描述 –
看到我的意思'耙的輸出routes' –