I'm trying to iterate over each articles' pictures in an Atom feed. I have the following code which renders an Atom feed just fine, but am not sure if these are the correct image tags.
Any advice on what the optimal setup for this is would be amazing.
This renders the XML below; index.atom.builder:
atom_feed do |feed|
feed.title "posts"
feed.updated @articles.maximum(:updated_at)
@articles.each do |article|
feed.entry(article) do |entry|
entry.title article.title
entry.content(article.body, type: 'html')
entry.author do |author|
author.name article.author
if article.pictures.any?
article.pictures.each do |pic|
entry.logo image_tag pic.photo.url(:large)
end
end
end
end
end
end
XML output:
<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
<id>tag:HEROKU APP:/articles</id>
<link rel="alternate" type="text/html" href="herokuapp.com"/>
<link rel="self" type="application/atom+xml"herokuapp.com/articles.atom"/>
<title>posts</title>
<updated>2012-09-10T16:42:27Z</updated>
<entry>
<id>tag:herokuapp.com,2005:Article/9</id>
<published>2012-09-10T16:42:27Z</published>
<updated>2012-09-10T16:42:27Z</updated>
<link rel="alternate" type="text/html" href="herokuapp.com/articles/9-test-lorum"/>
<title>Test Lorum</title>
<content type="html">wddsadasdsadasd</content>
<logo><img alt="Alaska" src="/assets/articles/12/large/alaska.jpg?1347295345" /></logo>
<author>
<name>Andy</name>
</author>
</entry>