Do not rely on root_path. Redirect to / if not available.

This commit is contained in:
José Valim 2012-01-02 22:31:30 +01:00
parent 0f11226ced
commit 1ebcb09fc1
3 changed files with 12 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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