문제

I'm trying to generate atom feed for special offers. The controller works fine so the link http://localhost:3000/offers.atom render some xml. I have a list of offers in http://localhost:3000/offers page. For each offer I don't have the show page becouse the original product is in an other web site. So in http://localhost:3000/offers page I'm only listing the offers but if I click in a specific offer I'm redirected to another web site.

My problem is generating the atom xml file:

#app/views/offers/index.atom.builder
atom_feed do |feed|
  feed.title "title"
  feed.updated @offers.maximum(:updated_at)
  @offers.each do |offer|
    feed.entry(offer, url: offer.product_link) do |entry|
      entry.image image_tag(offer.img_link)
      entry.title offer.desc
      entry.description offer.desc
      entry.price offer.price
      entry.special_price offer.special_price
      entry.saving offer.saving
    end
  end
end

The validator find some errors in my xml file. This is my xml file:

<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <id>tag:localhost,2005:/offers</id>
  <link rel="alternate" type="text/html" href="http://localhost:3000"/>
  <link rel="self" type="application/atom+xml" href="http://localhost:3000/offers.atom"/>
  <title>title</title>
  <updated>2014-04-08T12:33:24Z</updated>
  <entry>
    <id>tag:localhost,2005:Offer/116</id>
    <published>2014-04-08T12:33:24Z</published>
    <updated>2014-04-08T12:33:24Z</updated>
    <link rel="alternate" type="text/html" href="http://e-commerce.centroservizirovigo.com/Detail.aspx?ProductId=2101845"/>
    <img>&lt;img alt="738750a1" src="http://e-commerce.centroservizirovigo.com//Images/1480/738750A1.jpg" /&gt;</img>
    <title>​Rilegatrice termica T400 GBC - 400 fogli - 4400411</title>
    <description>​Rilegatrice termica T400 GBC - 400 fogli - 4400411</description>
    <price>167.7</price>
    <special_price>124.0</special_price>
    <saving>26.1</saving>
  </entry>
</feed>

But I have no idea to solve.

도움이 되었습니까?

해결책

The errors seem clear:

Undefined entry element: img
Undefined entry element: description
Undefined entry element: price
...

These are elements that you have used which are not defined by the Atom spec. They can't appear in your document unless you put them in a separate namespace (as Extensions from Non-Atom Vocabularies).

Missing entry element: author
Missing textual content

The Atom spec requires a minimum set of fields (bare minimum atom tags required for feed validity). You'll need to include them for a valid feed.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top