Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

layouts inheritance in controllers

#6587

I have a snippet:

class ProjectsController < ApplicationController
  layout "stream", :only => [:stream]
end

When I render projects#stream, it correctly uses the :stream layout. But when I render projects#show, it uses neither the :application nor the :stream layouts. It uses nothing, rending only show.html.erb.

Reported by Elben Shira · March 15th, 2011 @ 08:14 PM

State: new
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. ifesdjeen
    ifesdjeen

    You can use conditions for layouts, just give layouts a name of method to calculate current layout

    class ProjectsController < ApplicationController

    layout :get_layout_name
    
    def get_layout_name
       if action_name == "stream"
          "stream"
       else
          "application"
       end
    end
    

    end

    This way you will get your layouts working correctly

    March 19th, 2011 @ 10:33 AM