Iteration G2: Atom Feeds

By using a standard feed format, such as Atom, you can immediately take advantage of a wide variety of preexisting clients. Because Rails already knows about IDs, dates, and links, it can free you from having to worry about these pesky details and let you focus on producing a human-readable summary. We start by adding a new action to the products controller:

​ ​def​ who_bought
​  @product = Product.find(params[​:id​])
​  @latest_order = @product.orders.order(​:updated_at​).last
​  ​if​ stale?(@latest_order)
​  respond_to ​do​ |format|
​  format.atom
​  ​end​
​  ​end​
​ ​end​
Joe asks:
Why Atom?

A number of different ...

Get Agile Web Development with Rails 5, 1st Edition now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.