Doesn’t quite work that way. You have to use partials for this, or you just simply need to duplicate your layout and modify it for that controller.
A layout called “application.rhtml” will be used for all controllers. If you remove all other layouts, that one layout will be used everywhere automatically. If FooController needs a different layout, you then make a layout called ’
foo.rhtml’. It’s just a copy of ‘application.rhtml’ but it has the new stuff in there. The downside is that you’re modifying two layouts.
So the usual approach is to put the additional stuff into a partial.
Then in your layout (application.rhtml) put this code:
Finally, in your controller, you should be able to do this:
class FooController < ApplicationController
@custom_layout = render :partial=>“foo/layout”
That’s how I’ve done it in the past… it would be cool to hear other suggestions for this. You could also put ‘if’ statements in your layout… like
<% if controller_name == “foo” %>
<%=render :partial =>“foo/layout” %>
<% end %>
But I don’t like that so much if you’ve got lots of different layouts.