微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Rails 3-有关Atom Feed的帮助?

如何解决Rails 3-有关Atom Feed的帮助?

| 感觉就像我一直在转转,遵循了各种教程,都提出了达到预期结果的建议,但没有一个我有用。我正在使用Kaminari插件,并且我的文章在索引页面(6)。有人可以帮助我吗?谢谢 application.html.rb
auto_discovery_link_tag(:atom) # =>
<link rel=\"alternate\" type=\"application/atom+xml\" title=\"ATOM\" href=\"http://www.currenthost.com\" />
routes.rb
match \'/Feed\' => \'articles#Feed\',:as => :Feed,:defaults => { :format => \'atom\' }
article_controller.rb
def index
@articles = Article.published.page(params[:page]).per(6).ordered

respond_to do |format|
  format.html # index.html.erb
  format.atom  { @articles = Article.published }
  format.xml  { render :xml => @articles }
end
end
article / index.atom.builder
atom_Feed do |Feed|
Feed.title \"Title\"
Feed.updated(@articles.blank? ? Time.Now : @articles.first.created_at)

@articles.each do |article|
Feed.entry article do |entry|
entry.title article.title
entry.content article.body,:type => \'html\'

entry.author do |author|
author.name article.author
end
end
end
end
    

解决方法

        您的路线到达动作
feed
,但您的response_to块对应于动作
index
。您可能想要:
match \'/feed\' => \'articles#index\',:as => :feed,:defaults => { :format => \'atom\' }
    ,        在您的应用程序模板(
application.html.rb
)中,尝试以下操作:
<%= auto_discovery_link_tag(:atom,feed_path,{ :title => \"My ATOM Feed\" }) %>
    

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。