Resource_feeder, simply_restful and views

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 => {|o| render_to_string(:partial =>
‘show_text’, :locals => {:object => o, :fred => fred}) }
and for html descriptions,
:content_encoded => {|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.


“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 => {|o| object_url(,},

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