在網上Google了很多次,能找到用rails制作rss,但是總是找不到完整的。今天把完整的過程抄錄在這裡:
方法A:
就是你自己把RSS XML的格式拼湊好,輸出.並設置HTTP Header ,標記content-type為application/XML,常見的代碼:
#Post_controller::feed()
def feed
require "rss"
articles = Article.find :all, :order => 'post_date DESC', :limit => 10
feed = RSS::Maker.make("2.0") do |maker|
maker.channel.title = "Gang of Technology"
maker.channel.description = "Gang of Technology site"
maker.channel.link = "http://up-u.com"
maker.it