Domanda

I'm writing a full engine that will include devise following this guide. However, that guide is based on a mountable engine, not a full engine, which I think might be the cause of the following error:

RuntimeError: Rails::Application::RoutesReloader#execute_if_updated delegated to updater.execute_if_updated, but updater is nil: #<Rails::Application::RoutesReloader:0x007f843d9518e8 

routes.rb

Rails.application.routes.draw do

  # Some other stuff

  devise_for :users, {
    class_name: 'User',
    module: :devise
  }, controllers: {
    registrations: 'users/registrations', 
    sessions: 'users/sessions', 
    passwords: 'users/passwords'
  }
end

initializers/devise.rb

Devise.setup do |config|
  config.router_name = :user
  config.secret_key = 'secret_key'
end

lib/my_engine/engine.rb

module MyEngine
  class Engine < ::Rails::Engine
    require "devise"
  end
end
È stato utile?

Soluzione

Rails isn't showing you the proper error due to the issue found here: https://github.com/rails/rails/issues/10559

Try formatting the devise_for statement like this:

  devise_for :users, {
    class_name: 'User',
    module: :devise,
    controllers: {
      registrations: 'users/registrations', 
      sessions: 'users/sessions', 
      passwords: 'users/passwords'
    }
  }

It looks like your devise.rb file was generated by an older version of the gem. Try deleting devise.rb and running rails g devise:install

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top