Permalink
Browse files

Ensure Devise.available_router_name is never nil, closes #1648

  • Loading branch information...
1 parent 79aadb4 commit 27a83f3dd310c85119de239ac9a50c8953fc5abe @josevalim josevalim committed Feb 15, 2012
Showing with 9 additions and 5 deletions.
  1. +4 −0 lib/devise.rb
  2. +1 −1 lib/devise/controllers/url_helpers.rb
  3. +1 −1 lib/devise/failure_app.rb
  4. +3 −3 lib/devise/rails/routes.rb
View
@@ -299,6 +299,10 @@ def self.ref(arg)
end
end
+ def self.available_router_name
+ router_name || :main_app
+ end
+
def self.omniauth_providers
omniauth_configs.keys
end
@@ -60,7 +60,7 @@ def #{method}(resource_or_scope, *args)
private
def _devise_route_context
- @_devise_route_context ||= send(Devise.router_name)
+ @_devise_route_context ||= send(Devise.available_router_name)
end
end
end
@@ -89,7 +89,7 @@ def scope_path
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)
@@ -9,13 +9,13 @@ def finalize_with_devise!
@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

0 comments on commit 27a83f3

Please sign in to comment.