1.在LinksController
def feed@links = Link.all(:select => "title, url, id, description, updated_at", :order => "updated_at DESC", :limit => 20)respond_to do |format|format.htmlformat.rss { render :layout => false }endend
2.新增app/view/links/feed.rss.builder
xml.instruct! :xml, :version => "1.0"xml.rss :version => "2.0" doxml.channel doxml.title "learn rails"xml.description "study"xml.link links_urlfor link in @linksxml.item doxml.id link.idxml.title link.titlexml.description link.descriptionxml.pubDate link.updated_at.to_s(:rfc822)xml.link link.urlendendendend
3.html連結
<%= link_to("rss" , feed_links_path(rss))%>
如此 即可產生一可讓使用者訂閱之rss
沒有留言:
張貼留言