who_bought.atom.builder 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. atom_feed do |feed|
  2. feed.title "Who bought #{@product.title}"
  3. feed.updated @latest_order.try(:updated_at)
  4. @product.orders.each do |order|
  5. feed.entry(order) do |entry|
  6. entry.title "Order #{order.id}"
  7. entry.summary type: 'xhtml' do |xhtml|
  8. xhtml.p "Shipped to #{order.address}"
  9. xhtml.table do
  10. xhtml.tr do
  11. xhtml.th 'Product'
  12. xhtml.th 'Quantity'
  13. xhtml.th 'Total Price'
  14. end
  15. order.line_items.each do |item|
  16. xhtml.tr do
  17. xhtml.td item.product.title
  18. xhtml.td item.quantity
  19. xhtml.td number_to_currency item.total_price
  20. end
  21. end
  22. xhtml.tr do
  23. xhtml.th 'total', colspan: 2
  24. xhtml.th number_to_currency \
  25. order.line_items.map(&:total_price).sum
  26. end
  27. end
  28. xhtml.p "Paid by #{order.pay_type}"
  29. end
  30. entry.author do |author|
  31. author.name order.name
  32. author.email order.email
  33. end
  34. end
  35. end
  36. end