I'm using devise inside a Rails engine (my_app/components/base
) and override the registrations controller in order to forward the user to another page upon successful signup. This works quite well if I launch my_app
, but for whatever reason devise doesn't use my custom registrations controller when launching the engine from the spec/dummy
application that is generated for testing the engine.
The engine that uses devise is under main_app/components/base
My custom controller is main_app/components/base/app/controllers/base/users/registrations_controller.rb
module Base
class Users::RegistrationsController < Devise::RegistrationsController
layout 'base/application'
def after_sign_up_path_for(user)
fail # note: won't get called
base.welcome_new_user_path(user)
end
end
end
The engine's routes file is main_app/components/base/config/routes.rb
Base::Engine.routes.draw do
devise_for :users, {
class_name: "Base::User",
module: :devise,
controllers: { registrations: 'base/users/registrations' }
}
get 'users/welcome_new_user/:id' => "users/welcome#show", as: :welcome_new_user
end
rake routes
shows that the controller gets recognized:
cancel_user_registration GET /users/cancel(.:format) base/users/registrations#cancel
user_registration POST /users(.:format) base/users/registrations#create
new_user_registration GET /users/sign_up(.:format) base/users/registrations#new
edit_user_registration GET /users/edit(.:format) base/users/registrations#edit
PATCH /users(.:format) base/users/registrations#update
PUT /users(.:format) base/users/registrations#update
DELETE /users(.:format) base/users/registrations#destroy
user_confirmation POST /users/confirmation(.:format) devise/confirmations#create
new_user_confirmation GET /users/confirmation/new(.:format) devise/confirmations#new
GET /users/confirmation(.:format) devise/confirmations#show
welcome_new_user GET /users/welcome_new_user/:id(.:format) base/users/welcome#show
However, the custom registrations controller won't get used in the dummy app, thus failing my RSpec tests. The same happens if I interactively use the dummy app.
rails s
doesn't use the custom controller, too. – user1576088