title: JS format in the controller
body: <p>Let's assume I have a controller action that whenever you try to access it via a js format, I want to render nothing.</p>
  
  <pre><code>def no_js_please
    # there isn't a no_js_please partial or view
    respond_to do |format|
      format.html { # render a template }
      format.json { render json: {valid: true} }
      format.js { render nothing: true, status: :not_found }
    end
  end
  </code></pre>
  
  <p>When you access the endpoint via html or JSON, it works just fine. When you try to access it via JS it doesn't work. However, it does actually execute the block, because if I add a <code>binding.pry</code> within the js block, it gets picked up.</p>
  
  <p>However, this does work:</p>
  
  <pre><code>def no_js_please
    if request.format.js?
      render nothing: true, status: :not_found
    end
  end
  </code></pre>
  
  <p>So what's the difference between the two?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>As a human mentioned below, what's the actual error? So, in this particular case, it raises a <code>ActionController::InvalidCrossOriginRequest</code>.</p>