Help us understand the problem. What is going on with this article?

RailsでActiveAdminインストール時にraise_no_devise_method_error!が出る

More than 3 years have passed since last update.

既にAdminというモデルが存在しdeviseも利用していた。
ActiveAdminを導入しようとしたらraise_no_devise_method_error!が発生した。

$  bundle exec rails g active_admin:install --skip-users      
/Users/kenjikinukawa/bp/epf-backend/vendor/bundle/ruby/2.3.0/gems/devise-4.2.0/lib/devise/rails/routes.rb:508:in `raise_no_devise_method_error!': Admin does not respond to 'devise' method. This usually means you haven't loaded your ORM file or it's being loaded too late. To fix it, be sure to require 'devise/orm/YOUR_ORM' inside 'config/initializers/devise.rb' or before your application definition in 'config/application.rb' (RuntimeError)
    from /Users/kenjikinukawa/bp/epf-backend/vendor/bundle/ruby/2.3.0/gems/devise-4.2.0/lib/devise/rails/routes.rb:244:in `block in devise_for'
    from /Users/kenjikinukawa/bp/epf-backend/vendor/bundle/ruby/2.3.0/gems/devise-4.2.0/lib/devise/rails/routes.rb:240:in `each'
    from /Users/kenjikinukawa/bp/epf-backend/vendor/bundle/ruby/2.3.0/gems/devise-4.2.0/lib/devise/rails/routes.rb:240:in `devise_for'
    from /Users/kenjikinukawa/bp/epf-backend/config/routes.rb:3:in `block in <top (required)>'
....

config/initializers/devise.rbにrequire 'devise/orm/YOUR_ORM'したら?と言われているが、既に記述されている。
どうやら、Adminモデルが既に存在していると、default_namespaceの設定でコケるらしい。
そこで、default_namespaceを少し変更してやる。

config/initializers/devise.rb
# config.default_namespace = :admin
config.default_namespace = :admin_page

その後、

$ bundle exec rails g active_admin:install --skip-users

してやるとコンフリクトしているから上書きするか?と聞かれるのでnをすればgenerate active_admin:assetsが通る。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした