I'm building an engine that uses devise inside for user authentication. I have followed the instructions in the wiki (https://github.com/plataformatec/devise/wiki/How-To:-Use-devise-inside-a-mountable-engine) but I couldn't make it work as expected. It seems that router_name is being ignored. Maybe I'm miss understanding something.
I have created a simple engine with a dummy app that reproduces my issue. You can find it here: https://github.com/bilby91/devise_mountable_engine_issue. In the spec/dummy app there is a authenticated route under / path. When user is redirected to the sign_in path, the route doesn't build correctly and ignores the router_name.
I could make it work by providing a custom FailureApp to warden that handles the redirect.
module MyEngine
class FailureApp < Devise::FailureApp
def redirect_url
engine_route = Rails
.application
.routes
.routes
.select { |r| r.app.app == MyEngine::Engine }
.first
"#{engine_route.path.spec.to_s}/users/sign_in"
end
#
# # You need to override respond to eliminate recall
def respond
if http_auth?
http_auth
else
redirect
end
end
end
end
I really don't like this solution :(. Any help is more than welcome!
Thanks!
I'm building an engine that uses devise inside for user authentication. I have followed the instructions in the wiki (https://github.com/plataformatec/devise/wiki/How-To:-Use-devise-inside-a-mountable-engine) but I couldn't make it work as expected. It seems that
router_nameis being ignored. Maybe I'm miss understanding something.I have created a simple engine with a dummy app that reproduces my issue. You can find it here: https://github.com/bilby91/devise_mountable_engine_issue. In the
spec/dummyapp there is a authenticated route under/path. When user is redirected to the sign_in path, the route doesn't build correctly and ignores therouter_name.I could make it work by providing a custom FailureApp to warden that handles the redirect.
I really don't like this solution :(. Any help is more than welcome!
Thanks!