title: Rails: Undefined method `flash' for ActionDispatch::Request
body: <p>I'm trying to write an Ember application in Rails 4, and have decided to go with <code>rails-api</code> for the api controllers, while keeping the application controller intact for a few pages that aren't part of the single-page app.  To put it in more concrete terms, here are my controllers:</p>
  
  <p><code>app/controllers/application_controller.rb</code>:</p>
  
  <pre><code>class ApplicationController &lt; ActionController::Base
    protect_from_forgery
  end
  </code></pre>
  
  <p><code>app/controllers/sample_controller.rb</code>:</p>
  
  <pre><code>class SampleController &lt; ApplicationController
    # my methods
  end
  </code></pre>
  
  <p><code>app/controllers/api/v1/api_controller.rb</code>:</p>
  
  <pre><code>class Api::V1::ApiController &lt; ActionController::Api
    include ActionController::MimeResponds
  end
  </code></pre>
  
  <p><code>app/controllers/api/v1/sample_controller.rb</code>:</p>
  
  <pre><code>module Api::V1
    class SampleController &lt; ApiController
      respond_to :json
  
      # my methods
  
    end
  end
  </code></pre>
  
  <p>My <code>application.html.slim</code> contains the following line:</p>
  
  <pre><code>== render partial: "flash_msgs" unless flash.blank?
  </code></pre>
  
  <p>The inclusion of which results in the following error:</p>
  
  <blockquote>
    <p>undefined method 'flash' for #&lt; ActionDispatch::Request:0x007f99f41d8720 ></p>
  </blockquote>
  
  <p>Per discussion <a href="https://stackoverflow.com/questions/8855060/undefined-method-flash-for-actiondispatchrequest">on this thread</a>, it seems that the culprit could be <code>rails-api</code>, but I'm not entirely convinced given the inheritance I've set up. Any suggestions?</p>