John Mcleod wrote:
I have two different layouts (standard page and dialog box) for a view
(show).
How do I set each layout in the controller to show the different layout?
I don't know exactly what you're trying to accomplish from the
information you provided, but this approach doesn't "feel" right to me.
I would put the content of the page/dialog into a partial. I'm going to
assume that your dialog version will be rendered by an AJAX call.
In that case I would use respond_to to determine which layout to render:
respond_to do |format|
format.html # Render page with default layout
format.js # Render the dialog version
end
In case you're not rendering the "dialog" version with AJAX then you
might want to use a custom MIME type to render the alternate layout:
respond_to do |format|
format.html # Render page with default layout
format.dlog # Render the dialog version as HTML using custom format
type
end
Where would I set the variable? in the show.html.erb?
I'm not sure how you will be determining which layout to use, but if you
absolutely had to store this in a variable you would need an instance
variable on your controller.
However, as I mentioned before moving the decision into the request
seems like the better approach.