PDA

View Full Version : Default Layout


rob
November 30th, 2005, 08:28 PM
I'm not sure if this is discussed anywhere in the Rails documentation or in the book, but if you want a default template on your Rails project and don't want to have to update each layout for each controller, simply use a layout in the app/views/layout folder called application.rhtml.

You can use code like this to detect which view or controller you're in:


if @params[:controller] = 'store'
# show this bit for the store, perhaps a cart?
end
if @params[:action] = 'checkout'
# show a site seal here perhaps? You get the idea! :)
end

Hope this helps!