Allow page after sign in to be configured.

This commit is contained in:
José Valim
2009-10-18 15:25:16 -02:00
parent b0a2da72b5
commit 9feb9455ce
5 changed files with 39 additions and 16 deletions

View File

@@ -11,7 +11,7 @@ class SessionsController < ApplicationController
def create
if authenticate(resource_name)
set_flash_message :success, :signed_in
redirect_back_or_to root_path
redirect_back_or_to home_or_root_path
else
unauthenticated!
render :new
@@ -31,4 +31,9 @@ class SessionsController < ApplicationController
flash.now[:failure] = I18n.t(:"#{resource_name}.unauthenticated",
:scope => [:devise, :sessions], :default => :unauthenticated)
end
def home_or_root_path
home_path = :"#{resource_name}_home_path"
respond_to?(home_path, true) ? send(home_path) : root_path
end
end