ActiveAdmin和“未初始化的常量InheritedResources :: Base”

时间:2012-11-21 21:13:09

标签: ruby-on-rails-3.2 activeadmin inherited-resources

我只是在试用ActiveAdmin。我有仪表板和一些资源工作,但现在当我运行例如一个rails生成器时,我得到了:

% rails generate scaffold Post name:string
.../.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/ext/module.rb:36:in `const_missing': uninitialized constant InheritedResources::Base (NameError)
    from .../.rvm/gems/ruby-1.9.3-p194@lap/gems/activeadmin-0.5.0/lib/active_admin/base_controller/menu.rb:2:in `<module:ActiveAdmin>'
    from .../.rvm/gems/ruby-1.9.3-p194@lap/gems/activeadmin-0.5.0/lib/active_admin/base_controller/menu.rb:1:in `<top (required)>'
    from .../.rvm/gems/ruby-1.9.3-p194@lap/gems/activeadmin-0.5.0/lib/active_admin/base_controller.rb:2:in `<top (required)>'
    from .../.rvm/gems/ruby-1.9.3-p194@lap/gems/activeadmin-0.5.0/lib/active_admin/resource_controller/actions.rb:2:in `<module:ActiveAdmin>'
    from .../.rvm/gems/ruby-1.9.3-p194@lap/gems/activeadmin-0.5.0/lib/active_admin/resource_controller/actions.rb:1:in `<top (required)>'
    from .../.rvm/gems/ruby-1.9.3-p194@lap/gems/activeadmin-0.5.0/lib/active_admin/resource_controller.rb:2:in `<top (required)>'
    from .../.rvm/gems/ruby-1.9.3-p194@lap/gems/activeadmin-0.5.0/lib/active_admin/batch_actions.rb:7:in `block in <top (required)>'
    from .../.rvm/gems/ruby-1.9.3-p194@lap/gems/activeadmin-0.5.0/lib/active_admin/event.rb:25:in `call'
    from .../.rvm/gems/ruby-1.9.3-p194@lap/gems/activeadmin-0.5.0/lib/active_admin/event.rb:25:in `block in dispatch'
    from .../.rvm/gems/ruby-1.9.3-p194@lap/gems/activeadmin-0.5.0/lib/active_admin/event.rb:24:in `each'
    from .../.rvm/gems/ruby-1.9.3-p194@lap/gems/activeadmin-0.5.0/lib/active_admin/event.rb:24:in `dispatch'
    from .../.rvm/gems/ruby-1.9.3-p194@lap/gems/activeadmin-0.5.0/lib/active_admin/application.rb:179:in `load!'
    from .../.rvm/gems/ruby-1.9.3-p194@lap/gems/activeadmin-0.5.0/lib/active_admin/application.rb:205:in `routes'
    from .../.rvm/gems/ruby-1.9.3-p194@lap/gems/activeadmin-0.5.0/lib/active_admin.rb:79:in `routes'
    from .../lap-app/config/routes/routes.rb:27:in `block in <top (required)>'
    from .../.rvm/gems/ruby-1.9.3-p194@lap/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:282:in `instance_exec'
    ...

routes.rb:27是:

ActiveAdmin.routes(self)

我发现没有什么对我有用:((

由于

2 个答案:

答案 0 :(得分:0)

您是否意外注册了非模型的东西(使用rails g active_admin:resource NAME)? ActiveAdmin.routes(self)为您注册的资源自动生成CRUD路由,因此其中一个注册资源实际上不是一个。

如果您想为非模型注册某个页面并且您已经注册了该页面,请在.rb中使用ActiveAdmin.register_page“NAME”替换ActiveAdmin.register NAME

答案 1 :(得分:0)

尝试将ActiveAdmin.routes(self)移至顶部,而不是routes.rb文件的中间或末尾。