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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:21:21+00:00 2026-06-14T01:21:21+00:00

I have a rails app using backbone, but when I call save, the server

  • 0

I have a rails app using backbone, but when I call save, the server is redirecting to login – even though I’m already logged in (the page on which the backbone model is found is only shown after logging in).

I’m using backbone.matroyshka for nested models – but removing it doesn’t solve the problem.

Here’s the code that calls save on the model in the view:

    var view = this;

// save model
this.model.save(null, {
    success: function(model, response) {
        view.$('#saving').hide();
        view.notice('Saved!', 'success');
    },
    error: function(model, response) {
        view.$('#saving').hide();
        view.notice(response, 'error');
        console.log('save failed ' + response, view.model.get('url'));
    }
});

Prior to the model.save request, there is an AJAX request to retrieve data using jQuery AJAX:

        $.ajax({
        type: 'GET',
        url: serverUrl,
        data: { url: model.get('url') },
        dataType: "json", 
        context: this,
        success: function(data) {
            model.set(data);
        },

        error: function(xhr, status, error) {
            console.log('lookup share url failed ' + error, this.get('source'),         this.get('about'));
            this.trigger('load:fail');
            if (options.error) {
                options.error(this, error);
            }
        }
    });

The model.save receives a 302 found from the server, redirecting it to the login page.
The controller for the resource is protected by

  before_filter :signed_in_user, only: [:create]

signed_in_user is in a session helper taken straight from a tutorial on using omni_auth

  def signed_in_user
unless signed_in?
  store_location
  redirect_to login_path, notice: "You must be logged in to find out what they do."
end

end

I have another page that saves with AJAX (not backbone), and it works fine (also requires a signed in user).

  • 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-14T01:21:22+00:00Added an answer on June 14, 2026 at 1:21 am

    I don’t have much experience with Backbone but it sounds like it’s not sending the CSRF token.

    This article should be helpful:
    http://ngauthier.com/2011/02/backbone-and-rails-forgery-protection.html

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

Sidebar

Related Questions

I have a Rails 3.2.3 app with Backbone.js and I'm using pushState on my
I have already implemented some AJAX pagination in my Rails app by using the
I have a Rails app using sqlite3. Anytime I want to save anything in
I have Rails app set up using Jruby with puma as the web server.
I have a rails app that is using Devise perfectly in development. I have
I have a rails app set up as an OAuth2 provider (using Doorkeeper). The
I have a Rails app that is served by Apache and Passenger, using only
I'm using the Simpleform gem for my rails app and I have a form
I have a RESTful resource in my Rails app called Photo. I'm using Paperclip
So I am using Devise for user authentication in my rails app. I have

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.