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 5998653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:26:12+00:00 2026-05-23T00:26:12+00:00

I have a rails app . I have created a sessionscontroller and want to

  • 0

I have a rails app . I have created a sessionscontroller and want to redirect to users page ‘/users’ once the user signs in. But the redirect doesnt seem to be happening.

class SessionsController < ApplicationController

  def create
     user = User.find_or_create_by_fbid(params[:user][:fbid]) #...Success
     user.update_attributes(params[:user])  #....Sucess
     sign_in(user)  # ....This occurs successfully 
     redirect_to users_path # .... Redirect doesnt occur on the browser side 
  end

end

The sign_in method is defined inside the Application Controller

class ApplicationController < ActionController::Base

  def sign_in(user)
    session[:fbid] = user.fbid
    @current_user = user
  end

end

Server Logs below . The redirect actually seems to be happening on the server side . But I do not see any change on the client side. The browser doesnt change page.

Server Logs

The UsersController

class UsersController < ApplicationController

  def index

    @users = User.all

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

  end

Original Ajax Post –

$.post("/sessions",{user:{name:profile.name, email:profile.email,fbid:profile.id}}); 

The redirect occurs successfully if I use a javascript redirect statement inside the $post() as a callback function .

$.post("/sessions",{user:{name:profile.name, email:profile.email,fbid:profile.id}},function( data ) {
          window.location="/users";
      }
    );
  • 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-23T00:26:13+00:00Added an answer on May 23, 2026 at 12:26 am

    You need to handle the response’s redirection in an ajax query. Normally the browser handles, but it won’t with ajax.

    From this SO question (edited slightly for your case)

    var params = {user:{name:profile.name, email:profile.email,fbid:profile.id}};
    $.ajax({
    type: "POST",
    url: "/sessions",
    data: params,
    dataType: "json",
    success: function(data, textStatus) {
        if (data.redirect) {
            // data.redirect contains the string URL to redirect to
            window.location.href = data.redirect;
        }
        else {
            // data.form contains the HTML for the replacement form
            $("#login_form").replaceWith(data.form);
        }
    }
    

    });

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

Sidebar

Related Questions

I have a rails app that has picked up a bit of traction, but
I have a Rails app that sets a cookie and does a redirect to
I have a Rails app that uses STI to handle different types of Users,
I have a rails app moving along fairly well, but the fact that I'm
I have a rails app I created with based on a DB with a
I have a rails 3 app that displays user submissions in order of how
I have a Rails app where users can follow one another. I've just discovered
I have the following situation in a Ruby on Rails app: user fills in
I have a rails app, where I have 2 models, user and notice. A
I have a Rails 3.1.3 app which uses devise for users authentication and soft-deletes

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.