Forum: Ruby on Rails resource_feeder, simply_restful and views

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.
Jodi S. (Guest)
on 2007-02-06 05:00
(Received via mailing list)
Greetings all.

This topic is not a question, but a 'how do I do that'.

If you've had the chance to use the rails resource_feeder plugin,
you'll love the ease with which rss/atom feeds can be rendered.

My grief came when I tried to juice up my rss/atom descriptions with
some sweet html, and came under the impression that item descriptions
were limited to the a single designated attribute on your model, so I
set out to improve resource_feeder to permit descriptions to be
specified by rendering a view...

turns out my assumption was wrong, and you can render a view using a
Proc and render_to_string as follows:

for plain text descriptions,
   :description => Proc.new {|o| render_to_string(:partial =>
'show_text', :locals => {:object => o, :fred => fred}) }
and for html descriptions,
  :content_encoded => Proc.new {|o| render_to_string(:partial =>
'show_html', :locals => {:object => o, :fred => fred}) }

that's it - now your rss/atom descriptions will be rendered from the
partial 'show'. Just remember to use render_to_string otherwise
you'll get a DoubleRender exception.

note: in order to use resource_feeder and the latest simply_helpful,
you'll have to manually [1]patch resource_feeder to match new
simply_helpful packaging.

[1] http://dev.rubyonrails.org/ticket/7468

"One last thing" - if you're feeding a nested resource, you may have
to use the link option - I couldn't get nested routes to work  and
had to specify the option link as :
   :link => Proc.new {|o|  object_url(master_object_objectt.id, o.id)},

that's it - happy feeding all, and thanx to team-core for the Proc
interface.

Jodi
This topic is locked and can not be replied to.