我定义了一个控制器: 热潮/管理/ payment_members_controller.rb
module Spree
module Admin
class PaymentMembersController < ResourceController
def index
end
end
end
end
在文件config / routes
中Spree::Core::Engine.routes.append do
namespace :admin do
resources :payment_members
end
end
路线:
admin_payment_members_path GET /admin/payment_members(.:format) spree/admin/payment_members#index
POST /admin/payment_members(.:format) spree/admin/payment_members#create
new_admin_payment_member_path GET /admin/payment_members/new(.:format) spree/admin/payment_members#new
edit_admin_payment_member_path GET /admin/payment_members/:id/edit(.:format) spree/admin/payment_members#edit
admin_payment_member_path GET /admin/payment_members/:id(.:format) spree/admin/payment_members#show
PATCH /admin/payment_members/:id(.:format) spree/admin/payment_members#update
当我到达网址&#34; http://localhost:3000/admin/payment_members&#34; (索引)在浏览器中: 在控制台中:
Processing by Spree::Admin::PaymentMembersController#index as HTML
NameError (uninitialized constant Spree::PaymentMember):
activesupport (4.1.6) lib/active_support/inflector/methods.rb:253:in `const_get'
activesupport (4.1.6) lib/active_support/inflector/methods.rb:253:in `block in constantize'
..........
请告诉我,如何修复此错误?
答案 0 :(得分:1)
根据您在before_filter
中使用ResourceController
的控制器名称尝试load the resource。你创建了Spree:: PaymentMember
吗?
我建议您创建Spree::PaymentMember
(app / models / spree / payment_member.rb)或覆盖load_resource
中的PaymentMembersController
方法。