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

  • Home
  • SEARCH
  • 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 6595081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:53:37+00:00 2026-05-25T17:53:37+00:00

Im using devise with omniauth for signing in users with facebook. I want them

  • 0

Im using devise with omniauth for signing in users with facebook. I want them to be redirected after signing in to the page they were on after before signing in.

I’ve used the

  def after_sign_in_path_for(resource_or_scope)
    store_location = session[:return_to]
    clear_stored_location
    (store_location.nil?) ? "/" : store_location.to_s
  end

in my application controller, and made a sessions_helper with this code

  def deny_access
    store_location
    redirect_to new_user_session_path
  end

  def anyone_signed_in?
    !current_user.nil?
  end

  private

    def store_location
      session[:return_to] = request.fullpath
    end

    def clear_stored_location
      session[:return_to] = nil
    end

And to fix the problem with being redirected to “services/” where I have the logic for the authentication with facebook and other platforms I’ve used the

skip_before_filter :store_location

in services and other controllers that I don’t to be stored as locations.

Q1 The problem I’m having now is when I use ajax and render a login form in a modal window is that when a user successfully signs in it gets redirected to /users/sign_in/. I don’t have a user controller and tried to make a sessions_controller.rb and added the skip_before… there but it doesn’t work.

This is my routes for sign_in

new_user_session       GET   /users/sign_in(.:format)    {:action=>"new", :controller=>"devise/sessions"}
    user_session      POST   /users/sign_in(.:format)    {:action=>"create", :controller=>"devise/sessions"}
destroy_user_session   GET   /users/sign_out(.:format)   {:action=>"destroy", :controller=>"devise/sessions"}

Q2 I’ve tried to use the redirect when users sign out

  def after_sign_out_path_for(resource_or_scope)
      (session[:return_to].nil?) ? "/" : session[:return_to].to_s
  end

But that only redirects me to the root page.

I really appreciate any help in this,

  • 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-25T17:53:38+00:00Added an answer on May 25, 2026 at 5:53 pm

    I answered this here

    Devise doesn't redirect properly to stored location when using omniauth provider like facebook

    in application_controller.rb

     def after_sign_in_path_for(resource_or_scope)
       if request.env['omniauth.origin']
          request.env['omniauth.origin']
        end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using OmniAuth + Devise to allow users to register using Facebook/Twitter/Gowalla/etc attached to
I'm using DEvise for registration and omniauth for authentication through twitter/facebook, I want to
I'm using Omniauth with Devise to authenticate users via Facebook for a web app
I'm using omniauth and devise to log users in with their facebook acounts, everything
I'm want to test my login through facebook. Im using pure omniauth, w/o Devise.
I am using Omniauth and Devise. Users using gmail or FB can easily create
I want to suspend users in my Rails application. I am using Devise. I
I need some clarification with Omniauth for facebook and twitter. I m using Devise
I'm using devise/omniauth to do facebook authentication and works great. However, I would like
I have successfully implemented login with Facebook using Devise and OmniAuth (built into Devise).

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.