Rss feed items disappear using feedtools?


#1

I have met a problem on Feedtools and felt very confused about it:
The feed that I generated using feedtools can not be read correctedly by
feedtools,while rss from other websites can be read.
Still,the code for rss generating:
def userrss
@user = User.find_by_id(params[:id])
@articles = @user.articles(:all,:order => ‘updated_at desc’,:limit
=> 15)
@headers[“Content-Type”] = “application/xml; charset=utf-8”
@feed = FeedTools::Feed.new
@feed.title = “#{@user.login}”
@feed.author = “#{@user.login }”
@feed.link = “http://localhost:3000
@feed.description = “rss for #{@user.login}”
@articles.each do|@article|
@feed_item = FeedTools::FeedItem.new
@feed_item.title = “title”
@feed_item.link = " http://localhost:3000/"
@feed_item.description = render_to_string(:layout => false,
:template => “feeds/view.rhtml”)
@feed.entries << @feed_item
end
end
and @feed.build_xml(‘rss’, 2.0) in the userrss.rxml file

the generated rss can be read by any desktop rss reader correctedly

Following is the code for rss read:
controller:
@feed = FeedTools::Feed.open(“http://127.0.0.1:3000/feeds/userrss/1”)
view:

<%= @feed.title %>

<%= @feed.description %>

<% for feed_item in @feed.items %>

<%= feed_item.title %>

<%= feed_item.description %>

<% end %>

The results show that @feed.items will be empty in the above
view,therefore only @feed.title,@feed.description and @feed.link can be
displayed,with the following items are left blank.

If I use <%= @feed.feed_data %> in the view,I can see the whole data
displayed normally with all the items of the channel_node,but the
@feed.items or @feed.entries will return empty, why? Can anybody here
help me with this problem?


#2


It is because of the extra code:
@headers[“Content-Type”] = “application/xml; charset=utf-8”
if I deleted it,then everything will be ok


#3

charlie wrote:

The results show that @feed.items will be empty in the above
view,therefore only @feed.title,@feed.description and @feed.link can be
displayed,with the following items are left blank.

So you can create a valid feed using this writing code and you can read
valid feeds using this reading code, but you can’t simultaneously read
and write valid code. I mentioned yesterday that reading and writing
simultaneously might not work.

You really should try debugging these problems by writing the feed out
to a file and then reading that file. That rules out many possible
sources of error that you won’t see in a production.

If that works, then why don’t you try starting two instances of webrick.
This could be a problem in allow_concurrency, or it could be that you
are overwriting your own values.

Ray