设计不会在rails引擎中获取命名空间模型

时间:2012-06-08 23:59:05

标签: ruby-on-rails-3 devise rails-engines

我想在单独的rails引擎中提取我的管理界面。 为管理员用户添加设备支持并不适合我。这是引擎代码:

管理员用户模型:

AppEditorial::Admin

引擎路线:

  devise_for :admins, :controllers => {
    sessions: "app_editorial/devise/sessions",
    registrations: "app_editorial/devise/registrations",
    confirmations: "app_editorial/devise/confirmations",
    class_name: "AppEditorial::Admin",
    module: :devise
  }

抛出错误:

/../inflector/methods.rb:229:in `block in constantize': uninitialized constant Admin (NameError)

这是有道理的,因为模型被命名为 AppEditorial :: Admin 。添加* class_name *选项也不起作用。

作为起点,我找到了本教程:Use-devise-inside-a-mountable-engine

devise_for的文档。

1 个答案:

答案 0 :(得分:4)

hoppla。明显的错误:

它应该是:

  devise_for :admins, {
    controllers: {
      sessions: "app_editorial/devise/sessions",
      registrations: "app_editorial/devise/registrations",
      confirmations: "app_editorial/devise/confirmations",
    },
    class_name: "AppEditorial::Admin",
    module: :devise
  }
跛脚:)