+45 70 27 40 08

sales@meeho.net

» Ruby on Rails: how to render a custom layout in a controller method

Posted by Kasper Tidemann on Tuesday 23rd of February 2010 01:31:59 AM

If you have a controller that uses a general layout, but you want to use a custom layout for one of your controller methods and the corresponding view, what you do is simply to add a render :layout => ‘my_layout’ to the method. Have a look at the below example:

class MyController < ApplicationController
layout ‘main’

 def my_method

   # Do stuff here…
   render :layout => ‘my_layout’

 end

end

 

If you have something to say, feel free to drop a comment below:

Type in your name here

Type in your e-mail address here

Type in your web site address here

 

+45 70 27 40 08
Open office hours

info@meeho.net

support@meeho.net

News from the Meeho!™ Blog:

02/14 2011 » Fixing the "NoMethodError: undefined method ‘to_sym' for false:FalseClass" error when working with I18n in Ruby on Rails

02/03 2011 » Soon to come: IMAP integration

01/27 2011 » Meeho!™ App version 1.0.3 is out!

01/26 2011 » Cool new iPad stand

We live at Diplomvej 381, 2800 Kgs. Lyngby, Denmark: