【问题标题】:Is there a way to override the AtomFeedBuilder updated_at value?有没有办法覆盖 AtomFeedBuilder updated_at 值?
【发布时间】:2012-09-03 11:52:13
【问题描述】:

根据documentation,条目的updatedDefaults to the updated_at attribute on the record if one such exists. 我正在尝试覆盖updated 值,但我在RSS 提要中获得了两个updated 字段。

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

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

...然后我的 RSS 提要中有两个 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>

【问题讨论】:

    标签: ruby-on-rails ruby actionview actionviewhelper


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2021-07-25
      • 2018-10-05
      • 1970-01-01
      • 1970-01-01
      • 2011-12-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-05
      相关资源
      最近更新 更多