Drew
Drew

Reputation: 2663

Circular dependency issue Rails 4

So I have a file in the lib directory. At the top of that file, I include the following:

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

Whenever I include that require, I get the following error message:

Circular dependency detected while autoloading constant AdminUser (RuntimeError)

In context:

/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)>'

Any ideas?

EDIT:

Here's the definition of the AdminUser class as generated by activeadmin:

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

Upvotes: 1

Views: 3776

Answers (1)

Nerve
Nerve

Reputation: 6881

This might not be an activeadmin issue directly. Several gems broke in some versions of rails 4(Circular dependency issue) due to call to unloadable. So, this might be from some other gem you might be using.

References:

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 (See last comment by Dan)

Upvotes: 2

Related Questions