Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4013114
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:19:52+00:00 2026-05-20T09:19:52+00:00

I am working on a new app and am trying to customize where Devise

  • 0

I am working on a new app and am trying to customize where Devise sends the signed in or newly registered User after the submission of the sign-in form.

I want to send the User back to the page where the sign-in action was called from so I have created these methods in application_controller.rb

class ApplicationController < ActionController::Base
  protect_from_forgery

  def store_location
    session[:origin_url] = request.request_uri if request.get? and controller_name != "user_sessions" and controller_name != "sessions"
  end

  def redirect_back_or_default(default)
    redirect_to(session[:origin_url] || default)
  end


  def after_sign_in_path_for(resource_or_scope)
  [#https://github.com/plataformatec/devise/wiki/How-To:-Redirect-to-a-specific-page-on-successful-sign-in][1]
    p "*********** About to check session"
    if session[:origin_url]
      p "*****************Redirecting after sign_in to " + session[:origin_url]
      redirect_back_or_default(docs_path)
      return #this syntax needs to be checked
    else
     super
    end
    return
  end
end

Here is the docs_controller, show action code:

  # GET /docs/1
  # GET /docs/1.xml
  def show
    @doc = Doc.find(params[:id])
    store_location

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @doc }
    end
  end

And here is the output from the server log:

"*********** About to check session"
"*****************Redirecting after sign_in to /docs/3"


Started GET "/users/sign_in" for 127.0.0.1 at Wed Mar 02 01:12:16 +0100 2011
  Processing by Devise::SessionsController#new as HTML
  User Load (0.9ms)  SELECT `users`.* FROM `users` WHERE `users`.`id` = 3 LIMIT 1
Redirected to http://localhost:3000/docs/3
Redirected to 
Completed   in 119ms

ActionController::ActionControllerError (Cannot redirect to nil!):


Rendered /home/jon/.rvm/gems/ruby-1.8.7-p334@rails3/gems/actionpack-3.0.5/lib/action_dispatch/middleware/templates/rescues/_trace.erb (2.7ms)
Rendered /home/jon/.rvm/gems/ruby-1.8.7-p334@rails3/gems/actionpack-3.0.5/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (955.7ms)
Rendered /home/jon/.rvm/gems/ruby-1.8.7-p334@rails3/gems/actionpack-3.0.5/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (986.3ms)

I’m using Rails 3.0.5

Thanks for any advice…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:19:52+00:00Added an answer on May 20, 2026 at 9:19 am

    after_sign_in_path_for (like the name says) should return a path and not do any redirect_to magic.

    Since you just return all over the place without any return value, Devise might get a nil from you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working on a new app and using restful-authentication. I was trying to make it
I am trying to add a new view to a working nav controller app.
I have a new app I'll be working on where I have to generate
I am working on the admin section of a new rails app and i'm
I'm kinda new to using Rails, and an app I am working on is
I've been working on a new app and was really hoping to implement a
I am working on a new web app in lotus/domino. I am newer to
Rather new to trying to get OpenGL ES working on the iPhone, but I've
I am working on a Google App Engine application and I am relatively new
I'm working to install Rails 3 on a new MacBook Pro... when trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.