有没有办法覆盖AtomFeedBuilder updated_at值?

时间:2012-09-10 15:18:20

标签: ruby-on-rails ruby actionview actionviewhelper

根据documentation,条目的updatedDefaults to the updated_at attribute on the record if one such exists.我试图覆盖updated值,但我得到两个updated我的RSS Feed中的字段。

如果我使用此(截断的)示例设置不同的更新值...

feed.entry(item) do |entry|
  entry.updated(item.not_the_updated_at_value.strftime("%Y-%m-%dT%H:%M:%SZ"))
end

...然后我最终在RSS Feed中有两个updated字段:

<entry>
    <id>1</id>
    <published>2010-03-30T13:11:07-07:00</published>
    <updated>2010-03-30T13:11:07-07:00</updated>
    <link rel="alternate" type="text/html" href="http://example.com/1"/>
    <title>Title</title>
    <content type="html">Content</content>
    <url>http://example.com/1/</url>
    <updated>2012-07-10T11:05:32Z</updated>
    <author>
      <name>Author</name>
    </author>
  </entry>

1 个答案:

答案 0 :(得分:2)

您必须将已发布和已更新的选项传递到条目中。

feed.entry(item, :published => item.published_at, 
                   :updated => item.published_at) do |entry|
  entry.content item.body, :type => 'html'
end
相关问题