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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:42:50+00:00 2026-06-17T23:42:50+00:00

I know this has been asked before, and I have it working, but I’m

  • 0

I know this has been asked before, and I have it working, but I’m not sure how/why it works and was hoping somebody could explain it to me.

I have a model and I’m changing only one attribute at a time. I don’t want to send the entire model to the server each time, as there is no need with edit in place editing.

I save the model like this


update_field: function(e){
    var value = $('#update').val();
    var key = $(e.currentTarget).parent().attr('id');
    MyModel.attributes[key] = value;
    MyModel.save({key: value},{patch: true},{
                success: function(){
                    alert('saved');
                },
                error: function(){
                    alert('problem updating recipe');
                }});
    },

when I view the payload of what is sent to the server, the entire model is being sent, but the rails console only shows the updated field being updated. I find this impressive, but confusing at the same time. How does it know what needed to be updated.

I think my largest complaint with this is that Paperclip attempts to save an attachement, even though no attachement is being saved in the update.

Is there something I’m doing wrong here? How does Backbone tell Rails which attributes to update.
Is there a way to truly only send the necessary attributes?

Also, for some reason my success function isn’t being triggered. Though I doubt that is related.

  • 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-17T23:42:51+00:00Added an answer on June 17, 2026 at 11:42 pm

    The patch synchronization doesn’t send the whole model, it only sends the attributes you provide to model.save() as the first argument:

    model.save({foo: 'bar'}, {patch:true}); // -> PATCH /model/id {foo:bar}
    

    I’m going to go on a limb here and guess that you’re using an older version of Backbone. PATCH support was only added in 0.9.9, and in the earlier versions the patch:true argument would simply ignored. If this is correct, then you’re actually sending a PUT request to the resource.

    I don’t know enough Rails to say what it means when you say that the console shows only the updated fields being updated, but since you’re sending an update after every field change, then ActiveRecord / whatever ORM you might be using is probably intelligent enough to only copy and update the fields that have actually changed — in your case, the field that you expected, because all the other fields match the fields already in your database.

    Or then I could be completely off-base, and there is actually something else wrong. Please reply if this is the case, and I’ll edit / delete my answer.

    Edit: Also, your success handler is not being called, because you pass it incorrectly. Instead of passing three arguments as you do here:

    MyModel.save({key: value},{patch: true},{success:...});
    

    The save method only expects two arguments, the attributes to set, and the options hash, which may define multiple options, including patch and success:

    MyModel.save({key: value},{patch: true, success:...});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this has been asked before, but nothing is working. I have signed
I know this has been asked before, but I did not find its answer
I know this has been asked before but I have looked at every answer
I know this has been asked before, but the only answers I have found
I know this has been asked before but there is really not a clear
I know this has been asked a couple of times before, but not of
I know this question has been asked before but I have a design question
I'm sorry if this question has been asked before, but I'm not even sure
I know this has been asked before but all the answers I found didn't
I know this has been asked before, but I just cant seem to find

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.