我们正在 spec/dummy 下测试 customerx 引擎。引擎customerx的索引页可以正常显示。链接在这里:
<li><%= link_to 'Customers', customerx.customer_status_categories_path %></li>
但是uninitialized constant CustomerStatusCategoriesController
,新客户链接出现路由错误,如下所示:
<li><%= link_to 'New Customer', customerx.new_customer_status_category_path %></li>
确实显示了正确的rake routes
新客户路线:
Routes for Customerx::Engine:
customer_status_categories_index GET /customer_status_categories/index(.:format) customer_status_categories#index
customer_status_categories_new GET /customer_status_categories/new(.:format) customer_status_categories#new
customer_status_categories_create GET /customer_status_categories/create(.:format) customer_status_categories#create
customer_status_categories_edit GET /customer_status_categories/edit(.:format) customer_status_categories#edit
customer_status_categories_update GET /customer_status_categories/update(.:format) customer_status_categories#update
customer_status_categories GET /customer_status_categories(.:format) customerx/customer_status_categories#index
POST /customer_status_categories(.:format) customerx/customer_status_categories#create
new_customer_status_category GET /customer_status_categories/new(.:format) customerx/customer_status_categories#new
edit_customer_status_category GET /customer_status_categories/:id/edit(.:format) customerx/customer_status_categories#edit
customer_status_category PUT /customer_status_categories/:id(.:format) customerx/customer_status_categories#update
在引擎 customerx 的 routes.rb 中,资源声明为:
resources :customer_status_categories, :only => [:index, :new, :create, :edit, :update]
编辑/索引没有路由错误。新/创建所有通行证的 rspec 案例。问题似乎是没有找到new的动作(删除new和create的def后错误是一样的)。
导致错误的代码可能有什么问题?感谢帮助。