Friday, February 13, 2009

Displaying Rss in rails

hi,
i have displayed an array as rss feeds, using rails..

here s the code..
In the controller,

h={}
h[:summary] =summary
h[:description]=description
h[:dtstart]=dtstart.to_s
h[:url]=url
@arr << h

render :layout =>false
response.headers["Content-Type"]= "application/xml; charset=utf-8"

In the View file., Filename is , *.rxml

xml.instruct!
xml.rss "version" => "2.0", "xmlns:dc" => "http://purl.org/dc/elements/1.1/" do
xml.channel do |feed|
feed.title("My great blog!")
feed.description("description")
feed.link("ur url link")

@arr.each { |p|
feed.item do |item|
item.title p[:summary]
item.description p[:description]
item.link p[:url]
item.pubdate p[:dtstart]
end
}
end
end

now it is displayed as xml feed in the view file..
Thanks .

No comments: