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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:10:00+00:00 2026-06-18T08:10:00+00:00

Without remote: true in my form, the login works. But, when using remote: true

  • 0

Without remote: true in my form, the login works. But, when using remote: true, and attempting to login via ajax, I receive this error:

You need to sign in or sign up before continuing.

The requests are both post. Can somebody enlighten me?

  • 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-06-18T08:10:01+00:00Added an answer on June 18, 2026 at 8:10 am

    There are some steps that you need to follow:

    1) Check whether the request made is of javascript.

    To verify that you should check the request header to see what the Accept parameter is. If it says application/javascript then it’s all good. Use tools like firebug to check the request headers easily.

    2) What javascript files are included?

    Secondly, a very common problem when starting to try out the :remote => true is that the required javascript libraries are not included in your code. So my guess is that the following code is missing from your layout:

    <%= javascript_include_tag :defaults %>
    <%= csrf_meta_tag %>
    

    If that is the case, just include it inside the html header.

    3) Check the controller: does it have a respond_to block?

    If you generated your app with rails generate scaffold, it will have something like

     respond_to do |format|
          format.html
          format.xml  { .... }
        end
    

    Replace the above code with:

    respond_to :html, :js
    

    OR

    respond_to do |format|
          format.html
          format.js
          format.xml  { .... }
        end
    

    4) Setup CSRF Token in your application.js

    $(function(){
      $.ajaxSetup({
        beforeSend: function( xhr ) {
          var token = $('meta[name="csrf-token"]').attr('content');
          if (token) xhr.setRequestHeader('X-CSRF-Token', token);
        }
      });
    });
    

    5) Post your login information

    $.ajax({
      url: '/users/sign_in.json',
      type: 'POST',
      dataType: 'json',
      data: {user: {email: 'email@example.com', password: 'password'}},
      success: function(data, textStatus, xhr) {
        //called when successful
      }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Don't know why this is happening, but after submitting a form via JS (using
Im trying do build a form using ajax. I read this tutorial, but it
The below code works without error: = form_for @blog.comments.build, :remote => true do |f|
I need advice for a form with :remote => true. I need remote =>
It's not the only remote form I'm using, but I can't see the problem
I've followed this Railscast on submitting a form via Ajax and updating a div
remove() method without any argument removes all documents inside the collection. $this->db->$collection->remove(); But how
Im trying to toggle a button without refreshing using ajax In my micropost_helper.rb def
Im using ajax to toggle a like button without a page refresh. For some
The HTML form: <form id=newsletter method=post action=/subscribers data-remote=true> <label for=email>Enter your email:</label> <input type=text

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.