title: Rails API: make application controller serve JSON
body: <p><a href="http://fancypixel.github.io/blog/2015/01/28/react-plus-flux-backed-by-rails-api/" rel="nofollow">This tutorial</a>, <em>React + Flux Backed by Rails API</em>, by Fancy Pixel, says:</p>
  
  <blockquote>
    <p>Now we need to change the application controller so that it inherits
    from ActionController::API, and kiss the protect_from_forgery goodbye.
    Since we are serving only JSON, it makes sense to add</p>
  
  <pre><code>respond_to :json
  </code></pre>
    
    <p>to the applciation controller, helps DRYing all out. While we are at
    it, we might as well delete the assets and views folders, we won’t
    need them.</p>
  </blockquote>
  
  <p>I am not sure about what I am supposed to do.</p>
  
  <p>This is what my application controller looks like:</p>
  
  <pre><code>class ApplicationController &lt; ActionController::API
      respond_to :json
  end
  </code></pre>
  
  <p>Is it correct?</p>
  
  <p>Also, should I keep or remove <code>protect_from_forgery with: :null_session</code> : </p>
  
  <pre><code>class ApplicationController &lt; ActionController::API
    protect_from_forgery with: :null_session
    respond_to :json
  end
  </code></pre>