title: How to set a global property in a Rails app for the layout with a default value that can be overridden in controller
body: <p>I'd like to have a single layout.html.erb with a few variables that can be overridden in the controller such as bootstrap's "container" and "container-fluid". </p>
  
  <p>I was thinking of having a helper like this:</p>
  
  <pre><code>module ApplicationHelper
    def which_layout
      @layout || "container"
    end
  </code></pre>
  
  <p>in controller: </p>
  
  <pre><code>  def holding
      @layout="container-fluid"
    end
  </code></pre>
  
  <p>and in layout:</p>
  
  <pre><code>&lt;div class='&lt;%=which_layout %&gt;'&gt;
  </code></pre>
  
  <p>but this is not working. Also, doing it in application_controller doesn't work. Such as:</p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
  
    @layout="container"
  </code></pre>
  
  <p>What would be an effective way to achieve this in as centralized place as possible? I might want to query in a helper which controller / method combo and output the appropriate layout value too.</p>
  
  <h2>Edit</h2>
  
  <p>So doing something like this in application.html.erb works:</p>
  
  <pre><code>  &lt;div class='&lt;%=@layout || "container" %&gt;'&gt;
  </code></pre>
  
  <p>and then just in a controller </p>
  
  <pre><code>  def holding
      @layout="container-fluid"
    end
  </code></pre>