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:
<div class="contentBox">
<h4><a href="<%= h @feed.link %>">
<%= @feed.title %></a></h4>
<p><%= @feed.description %></p>
<% for feed_item in @feed.items %>
<div class="feedItemBox">
<h5><a href="<%= h feed_item.link %>">
<%= feed_item.title %></a>
</h5>
<p><%= feed_item.description %></p>
</div>
<% end %>
</div>
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?
--
Posted via http://www.ruby-forum.com/.