diff --git a/app/controllers/devise/sessions_controller.rb b/app/controllers/devise/sessions_controller.rb index 2693fe61..45e2e3e3 100644 --- a/app/controllers/devise/sessions_controller.rb +++ b/app/controllers/devise/sessions_controller.rb @@ -10,7 +10,7 @@ class Devise::SessionsController < ApplicationController # POST /resource/sign_in def create - resource = warden.authenticate!(:scope => resource_name, :recall => "new") + resource = warden.authenticate!(:scope => resource_name, :recall => "#{controller_name}#new") set_flash_message :notice, :signed_in sign_in_and_redirect(resource_name, resource) end diff --git a/lib/devise/failure_app.rb b/lib/devise/failure_app.rb index e253f54e..4724b039 100644 --- a/lib/devise/failure_app.rb +++ b/lib/devise/failure_app.rb @@ -41,7 +41,7 @@ module Devise def recall env["PATH_INFO"] = attempted_path flash.now[:alert] = i18n_message(:invalid) - self.response = recall_controller.action(warden_options[:recall]).call(env) + self.response = recall_app(warden_options[:recall]).call(env) end def redirect @@ -94,8 +94,9 @@ module Devise {}.respond_to?(method) ? { :error => i18n_message }.send(method) : i18n_message end - def recall_controller - "#{params[:controller].camelize}Controller".constantize + def recall_app(app) + controller, action = app.split("#") + "#{controller.camelize}Controller".constantize.action(action) end def warden diff --git a/test/failure_app_test.rb b/test/failure_app_test.rb index 86a8c681..1a6a1bef 100644 --- a/test/failure_app_test.rb +++ b/test/failure_app_test.rb @@ -136,8 +136,7 @@ class FailureTest < ActiveSupport::TestCase context 'With recall' do test 'calls the original controller' do env = { - "action_dispatch.request.parameters" => { :controller => "devise/sessions" }, - "warden.options" => { :recall => "new", :attempted_path => "/users/sign_in" }, + "warden.options" => { :recall => "devise/sessions#new", :attempted_path => "/users/sign_in" }, "devise.mapping" => Devise.mappings[:user], "warden" => stub_everything }