title: Why does Rails render RJS templates within a layout?
body: <p>I need to do this for a controller which uses the <code>active_scaffold</code> gem.  We have a controller that looked something like this:</p>
  
  <pre><code>class Admin::UsersController &lt; ApplicationController
     layout 'admin'
  
     active_scaffold :users do |config|
       config.search.columns = [:first_name, :last_name]
     end
  end
  </code></pre>
  
  <p>That worked great when we were on Rails 2.3.10, but we're upgrading to Rails 3.0.10. As part of the upgrade, I had to upgrade <code>active_scaffold</code> (currently installed from the <code>rails-3.0</code> branch of <code>git://github.com/activescaffold/active_scaffold</code>) to be compatible.  One problem we were having is that searching the table wasn't working.  I would see in my log files:</p>
  
  <pre><code>Rendered &lt;snip&gt;/gems/active_scaffold-25b3d724f35b/frontends/default/views/list.js.rjs within layouts/admin (923.5ms)
  </code></pre>
  
  <p>Notice that it's rendering the RJS template with the layout specified in the controller.  That seems like an unreasonable default to me. Shouldn't RJS templates render <em>without</em> a layout <em>by default</em>? Anyway, I fixed it as such:</p>
  
  <pre><code>class Admin::UsersController &lt; ApplicationController
    layout :admin_layout
  
    private
  
    def admin_layout
      respond_to do |format|
        format.js   { false }
        format.html { 'admin' }
      end
    end
  end
  </code></pre>
  
  <p>That fixes the issues with search and pagination.  (The RJS template is now rendered without a layout, so the browser can execute the resulting Javascript).  I guess my question is, why do I have to tell Rails that it shouldn't render RJS templates with layouts? And is there a better solution? This feels like too much of a hack to me (the bad kind of hack---the kind of hack that will break in the future).</p>