1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

Ensure Devise.available_router_name is never nil, closes #1648

This commit is contained in:
José Valim 2012-02-15 17:13:55 +01:00
parent 79aadb4bc9
commit 27a83f3dd3
4 changed files with 9 additions and 5 deletions

View file

@ -299,6 +299,10 @@ module Devise
end
end
def self.available_router_name
router_name || :main_app
end
def self.omniauth_providers
omniauth_configs.keys
end

View file

@ -60,7 +60,7 @@ module Devise
private
def _devise_route_context
@_devise_route_context ||= send(Devise.router_name)
@_devise_route_context ||= send(Devise.available_router_name)
end
end
end

View file

@ -89,7 +89,7 @@ module Devise
route = :"new_#{scope}_session_path"
opts[:format] = request_format unless skip_format?
context = send(Devise.router_name)
context = send(Devise.available_router_name)
if context.respond_to?(route)
context.send(route, opts)

View file

@ -9,13 +9,13 @@ module ActionDispatch::Routing
@devise_finalized ||= begin
if Devise.router_name.nil? && self != Rails.application.try(:routes)
warn "[Devise] We have detected that you are using devise_for inside engine routes. " \
warn "[DEVISE] We have detected that you are using devise_for inside engine routes. " \
"In this case, you probably want to set Devise.router_name = MOUNT_POINT, where " \
"MOUNT_POINT is a symbol representing where this engine will be mounted at. For " \
"now, Devise will default the mount point to :main_app."
"now Devise will default the mount point to :main_app. You can explicitly set it" \
" to :main_app as well in case you want to keep the current behavior."
end
Devise.router_name ||= :main_app
Devise.configure_warden!
Devise.regenerate_helpers!
true