O'Reilly logo

Rails, Angular, Postgres, and Bootstrap, 2nd Edition by David B. Copeland

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Saving Changes to the Server

Although you know how to make an Ajax request, saving the data has a few subtleties. First, our events only have the field that was changed along with its new value, not the entire customer record. That means that ideally, we just post the customer ID and the changed field to the server. The second subtlety is translating a generic address change like “the zip code was updated” to the more specific change of “the billing zip code was updated.”

To do this, we’ll create a function called saveCustomerField that accepts the name of the field as sent from the server (such as shipping_street) and the new value. With this information we’ll use the patch function on Http and send a simple object mapping the field name ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required