O'Reilly logo

Rails, Angular, Postgres, and Bootstrap 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

Using Angular-Resource to Connect to Rails

The Rails way of designing HTTP endpoints (which is a RESTful style[77]) isn’t particular to Rails. It’s quite common outside the Rails world. Because of this, it’s possible to use a higher level of abstraction than what $http gives us. The Angular module angular-resource provides such an abstraction.

What it will allow us to do is to write code like so:

 $scope.customer = Customer.get(customer_id);

Although there are no callbacks, this code is still asynchronous. Execution continues after the call; it doesn’t wait for the Ajax call to complete. This is because the object returned by Customer.get is a promise that, when resolved, will behave like a customer object, exposing the various fields from ...

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