Forum: Ruby on Rails rss double render problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2a0f7bd2c54fbc44329d69555b96f1c5?d=identicon&s=25 Kev Jackson (Guest)
on 2005-12-14 09:19
(Received via mailing list)
I have a simple method

def activities
    @headers["Content-Type"] = "application/xml; charset=utf-8"

    activities = get_activities
    @feed = FeedTools::Feed.new
    @feed.title = "Activities"
    @feed.author = "Cogini"
    @feed.copyright = "Cogini 2005-2006"
    @feed.link = "http://localhost:3000/admin/customers/"
    @feed.content = "Activities"
    activities.each do |a|
      @feed_item = FeedTools::FeedItem.new
      @feed_item.feed = @feed
      @feed_item.content = activity_link(a)
      @feed.entries << @feed_item
    end
    render :inline => "<?xml version='1.0'
encoding='UTF-8'?>\n#{@feed.build_xml('rss', 2.0)}"
  end

That builds a feed from a set of fixed values + some dynamic data, but I
cannot get it to build the correct rss.

@feed.build_xml returns a string - not the XMLBuilder as promised, so I
simply concatenated the xml header and tried to render, but now I get a
DoubleRenderError - I can't see anywhere else in this where I render
previously

I've also looked at the xml howto and the feedtools tutorial, neither of
them adequately explain how to do what I want - indeed following them
hasn't brought me any closer to getting this working

Kev
Eb234d1ee9f1dcd334657d7c5c1b1c4d?d=identicon&s=25 Jamie Macey (jamie)
on 2005-12-14 19:13
(Received via mailing list)
On Wed, 2005-12-14 at 15:22 +0700, Kev Jackson wrote:
>     @feed.link = "http://localhost:3000/admin/customers/"
>
> hasn't brought me any closer to getting this working
>
> Kev

Three things that might help.

I think the problem is that you're doing an inline render, but the
method is finishing and it still wants to use the view template.

Solution one: move your inline render to the view, since you already
have @feed available.

Solution two: Not sure if this will work exactly, but what happens if
you render :text instead of :inline?

Solution three: Also not sure if this is the issue or not, but if you
return false from your action, I believe it should suppress rendering of
the template.

- Jamie
This topic is locked and can not be replied to.