I want to output RSS via Sinatra. I wrote below code, but it outputs nothing. Strangly, when I wrote puts before rss, it output rss correctly to console! Why I cannot output to browser?
#encoding: utf-8
require 'sinatra'
require 'rss'
...
get '/' do
...
rss = RSS::Maker.make("2.0") do |rss|
rss.channel.about = 'http://hoge/rss.xml'
rss.channel.title = "hoge"
...
end
content_type = 'application/xml'
# puts rss # => output correctly to console
rss # => output nothing
end
whole code: https://github.com/weed/p120905-rss-process-test/blob/master/app.rb
Thanks for your kindness.
Sinatra doesn’t seem to know what to do with the RSS object.
How about changing the last line in the get block to