Chapter 10. ActiveResource and Web Services

Your paradigm is so intrinsic to your mental process that you are hardly aware of its existence, until you try to communicate with someone with a different paradigm.

—Donella Meadows, Environmental Scientist

Web Services are systems used to allow machines to interact over a network. Within the context of Web development, the network is the Internet itself, and the interaction is between at least one computer that exposes a Web API and other machines that use this API to require services.

The previous chapters analyzed how you can define resources through ActionController::Resources and hence easily define a RESTful service that exposes an API. When the format requested was XML, Rails would formulate a response in XML that was suitable for other computers to understand.

Historically XML has been the lingua franca for communicating among machines. Another younger contender is JSON (JavaScript Object Notation).

What you did not explore yet, and what will be the main subject of this chapter, is how to consume REST Web Services that are defined through Rails. Enter the world of ActiveResource (also known as ARes).

Get Ruby on Rails® for Microsoft Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.