如何解决Rails RSS 提要未呈现为 XML
我有一些运行良好的 Atom Feed。我现在需要 Flipboard 的 RSS 提要,但是当我尝试生成它时,它没有呈现为 xml 并且看起来无效。
Routes.rb
get '/flipboard_feed',:controller => 'news_feed',:action => 'flipboard_feed',:format => 'rss'
控制器
def flipboard_feed
# this will be the name of the feed displayed on the feed reader
@title = "Feed title"
# the news items
@items = Content.published.limit(50)
respond_to do |format|
format.html
format.rss { render :layout => false }
end
end
然后我有一个flipboard_feed.rss.builder
xml.instruct! :xml,:version => "1.0"
xml.rss :version => '2.0' do
xml.channel do
xml.title @title
xml.link "#{root_url}flipboard_feed"
xml.description 'xxxx'
xml.language "it"
@items.each do |article|
xml.item do
xml.title article.name
xml.link show_resource_url(article)
xml.guid article.id
xml.pubDate article.published_at.to_s(:rfc822)
xml.dc(:creator,article.author_name)
xml.description article.summary
xml.enclosure $imgix.path(article.main_image.path).to_url(w: 1000,h: 500,fit: 'crop',auto:'format,compress')
xml.category article.sections.map(&:name).join(',')
end
end
end
end
提要已呈现,但它不是 xml 且未经验证。为什么?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。