Over a million developers have joined DZone.

More Rails Conditional Layouts

·
In your controller:


  layout :my_layout_func

  ...

protected

  def my_layout_func
   # anything ruby will work
   ['list','index',nil].include?(action_name)? 
   'noheading':'my_layout'
 
   # or you could do
   case action_name
    when 'monkey': 'monkey_layout'
    when 'edit'  : 'form_layout'
   end
 end



 
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}