【问题标题】:how add carrierwave image to atom feed rss in rails 3.1如何在rails 3.1中将载波图像添加到原子馈送RSS
【发布时间】:2012-01-27 10:33:26
【问题描述】:

我的问题是如何在 rails 中输出带有 rss/atom 的图像载波 3?

我试试:

atom_feed :language => 'en-US' do |feed|
  feed.title @title
  feed.updated @updated

  @posts.each do |item|
  next if item.created_at.blank?

    feed.entry( item ) do |entry|
     entry.url feed_url(item)
     entry.content item.content, :type => 'html'
      link_to (image_tag item.posted.url(:medium)), feed_url(item)

      # the strftime is needed to work with Google Reader.
      entry.updated(item.created_at.strftime("%Y-%m-%dT%H:%M:%SZ"))
      entry.author item.user.username
    end
  end
end

但我什么也看不见:O

如何将 link_to (image_tag item.posted.url(:medium)), feed_url(item) 添加到我的提要中?谢谢

【问题讨论】:

  • 你找到解决办法了吗?
  • 我还没有找到解决这个问题的办法。对不起:(

标签: rss ruby-on-rails-3.1 carrierwave feed atom-feed


【解决方案1】:

entry.link href: "#{base_url}#{some_variable.image.url(:medium)}", rel:"enclosure", type:"image/jpeg"

在一个助手中

def base_url request.protocol + request.host_with_port 结束

【讨论】:

    猜你喜欢
    • 2010-10-16
    • 1970-01-01
    • 2012-02-24
    • 2020-05-30
    • 2013-11-01
    • 1970-01-01
    • 2012-04-28
    • 2018-02-24
    • 2023-03-12
    相关资源
    最近更新 更多