views:

50

answers:

2

<%=yield%> works perfectly if my template is called layouts/application.erb. However, if I change the template to something else, then the yield doesn't work. For instance, my controller method is

render :template=>'layouts/survey'

and the right template gets rendered, but its yield method doesn't show the output of the current action's view. What simple thing am I missing? I have also tried

render :action=>"index", :template=>"layouts/survey"

to no avail.

+4  A: 

Are you sure you want to be using :template and not :layout?

Andy Gaskell
Thanks, that was it!
Yar
I'm going to give best answer to dmathieu, because he beat you to the punch and has 500 points only. Thanks again.
Yar
Didn't beat me to the punch but that's cool ;)
Andy Gaskell
+4  A: 

By "template" you mean the layout apparently. Then the option isn't the good one. It's :layout

render :action => 'index', :layout => 'survey'
Damien MATHIEU
What would template be for, then?
Yar
This might help explain - http://guides.rubyonrails.org/layouts_and_rendering.html#rendering-an-actions-template-from-another-controller
Andy Gaskell
Hmmm... I'll have to see the difference between :template=> and :action=>, then... thanks Andy.
Yar