title: How to fail Ajax request in Rails?
body: <p>When user clicks a specific item, I use <a href="http://api.jquery.com/jQuery.post/" rel="noreferrer">jQuery's post method</a> to update something in the database:</p>
  
  <pre><code>$.post("/posts/" + post_id + "/update_something", 
         { some_param: some_value }, 
         success_handler);
  </code></pre>
  
  <p>where <code>update_something</code> looks like this:</p>
  
  <pre><code>def update_something
    post = Post.find(params[:id])
    post.update_attributes(:some_field =&gt; params[:some_param])
    render :nothing =&gt; true
  end
  </code></pre>
  
  <p>The problem is if <code>update_attributes</code> fails, the request still succeeds and <code>success_handler</code> is executed.</p>
  
  <p>How could I cause the request to fail when <code>update_attributes</code> fails such that <code>success_handler</code> won't be executed?</p>