2

Hello in a helper I'm doing the following:

render(:template =>"feeds/_feed_item.html.erb", :locals => { :feed_item => feed_item }).to_s

Problem is this is rendering the layout which I don't want. How can I render just the file/template feed_item ?

Thanks

AnApprentice
  • 108,152
  • 195
  • 629
  • 1,012

2 Answers2

2

You can add the option :layout => false to render without the layout.

Example:

render(:template =>"feeds/_feed_item.html.erb", :layout => nil , :locals => { :feed_item => feed_item }).to_s
fresskoma
  • 25,481
  • 10
  • 85
  • 128
Devin M
  • 9,636
  • 2
  • 33
  • 46
1

If you use the :partial key, the template shouldn't be rendered. Try this:

render :partial => 'feeds/feed_item', :locals => { :feed_item => feed_item }).to_s

Depending on your setup, you may also be able to shorten this to simply:

render feed_item
dpb
  • 671
  • 3
  • 8