Tag: Rails3/RSSフィードの生成
def feed @posts = Post.all(:select => "title, author, id, content, posted_at", :order => "posted_at DESC", :limit => 20) respond_to do |format| format.html format.rss { render :layout => false } #index.rss.builder end end
xml.instruct! :xml, :version => "1.0" xml.rss :version => "2.0" do xml.channel do xml.title "Your Blog Title" xml.description "A blog about software and chocolate" xml.link posts_url for post in @posts xml.item do xml.title post.title xml.description post.content xml.pubDate post.posted_at.to_s(:rfc822) xml.link post_url(post) xml.guid post_url(post) end end end end