From 1ebcb09fc11030916cea8588cb97042772758a7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Mon, 2 Jan 2012 22:31:30 +0100 Subject: [PATCH] Do not rely on root_path. Redirect to / if not available. --- app/controllers/devise/registrations_controller.rb | 2 +- lib/devise/controllers/helpers.rb | 10 ++++++++-- lib/devise/failure_app.rb | 4 +++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/controllers/devise/registrations_controller.rb b/app/controllers/devise/registrations_controller.rb index 0a6aff0a..e1005505 100644 --- a/app/controllers/devise/registrations_controller.rb +++ b/app/controllers/devise/registrations_controller.rb @@ -96,7 +96,7 @@ class Devise::RegistrationsController < DeviseController # The path used after sign up for inactive accounts. You need to overwrite # this method in your own RegistrationsController. def after_inactive_sign_up_path_for(resource) - root_path + respond_to?(:root_path) ? root_path : "/" end # The default url to be used after updating a resource. You need to overwrite diff --git a/lib/devise/controllers/helpers.rb b/lib/devise/controllers/helpers.rb index 3da975fd..64aa4391 100644 --- a/lib/devise/controllers/helpers.rb +++ b/lib/devise/controllers/helpers.rb @@ -168,7 +168,13 @@ module Devise def signed_in_root_path(resource_or_scope) scope = Devise::Mapping.find_scope!(resource_or_scope) home_path = "#{scope}_root_path" - respond_to?(home_path, true) ? send(home_path) : root_path + if respond_to?(home_path, true) + send(home_path) + elsif respond_to?(:root_path) + root_path + else + "/" + end end # The default url to be used after signing in. This is used by all Devise @@ -209,7 +215,7 @@ module Devise # # By default it is the root_path. def after_sign_out_path_for(resource_or_scope) - root_path + respond_to?(:root_path) ? root_path : "/" end # Sign in a user and tries to redirect first to the stored location and diff --git a/lib/devise/failure_app.rb b/lib/devise/failure_app.rb index e923a5be..bf362288 100644 --- a/lib/devise/failure_app.rb +++ b/lib/devise/failure_app.rb @@ -75,8 +75,10 @@ module Devise if respond_to?(route) send(route, opts) - else + elsif respond_to?(:root_path) root_path(opts) + else + "/" end end