循环依赖问题Rails 4

时间:2013-11-12 17:27:17

标签: ruby-on-rails ruby ruby-on-rails-4 clockwork

所以我在lib目录中有一个文件。在该文件的顶部,我包含以下内容:

require File.expand_path('../../config/environment', __FILE__)

每当我包含该要求时,我都会收到以下错误消息:

Circular dependency detected while autoloading constant AdminUser (RuntimeError)

在上下文中:

/Users/ahcarpenter/.rvm/gems/ruby-1.9.3-p448@global/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:461:in `load_missing_constant': Circular dependency detected while autoloading constant AdminUser (RuntimeError)
    from /Users/ahcarpenter/.rvm/gems/ruby-1.9.3-p448@global/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:184:in `const_missing'
    from /Users/ahcarpenter/Dropbox/workspace/Web Applications/main-site/app/admin/admin_user.rb:1:in `<top (required)>'

有什么想法吗?

编辑:

以下是activeadmin

生成的AdminUser类的定义
ActiveAdmin.register AdminUser do
  index do
    column :email
    column :current_sign_in_at
    column :last_sign_in_at
    column :sign_in_count
    default_actions
  end

  filter :email

  form do |f|
    f.inputs "Admin Details" do
      f.input :email
      f.input :password
      f.input :password_confirmation
    end
    f.actions
  end
  controller do
    def permitted_params
      params.permit admin_user: [:email, :password, :password_confirmation]
    end
  end
end

1 个答案:

答案 0 :(得分:2)

这可能不是直接activeadmin问题。由于调用unloadable,一些版本的rails 4(循环依赖问题)中出现了几个宝石。所以,这可能来自你可能正在使用的其他宝石。

参考文献:

https://github.com/flyerhzm/switch_user/issues/34

https://github.com/thoughtbot/high_voltage/issues/68

https://github.com/websocket-rails/websocket-rails/issues/101(见丹的最后评论)