title: Rails 5 API always return 200 OK, even if a rollback occurs. Why?
body: <p>I have a very strange problem. I'm working with Rails 5 and Devise to build json based REST api, but for every request, I get always <code>200 OK</code> even if a <code>Rollback</code> occurs. For example:</p>
  
  <pre><code>curl -i -H "Content-Type: application/json" -d '{ "user": { "email": "user@example.com", "password": "123457890" } }' -X POST http://api.test.com:3000/users/registration
  </code></pre>
  
  <p>It normally stores the User into database, but for example if I post again the same request, a <code>Rollback</code> is performed on databse because email is an index (<strong>and is correct, is what I want...</strong>) but the response is again <code>200 OK</code>.</p>
  
  <p>Now, Devise controllers are overridden because I need to share them among different namespaces and modules, I override them as <a href="https://github.com/plataformatec/devise#configuring-controllers" rel="nofollow noreferrer">Devise/Wiki</a> suggest, with the default behaviour of:</p>
  
  <pre><code>def method
      super
  end
  </code></pre>
  
  <p>So, in a normal application, if some validation fails an error is returned to the User in the corresponding View, with the default controller (<strong>that are the same of mine, nothing is changed!</strong>). Why with "API only" application, each request seems is going always good? What am I forgetting?</p>
  
  <p>Thanks to all.</p>
  
  <p><strong>EDIT:</strong> server output.</p>
  
  <pre><code>Started POST "users/registration" for 127.0.0.1
  Processing by Users::RegistrationsController#create as */*
  Parameters: {"user"=&gt;{"email"=&gt;"user@example.com", "password"=&gt;" [FILTERED]"}, "registration"=&gt;{"user"=&gt;{"email"=&gt;"user@example.com", "password"=&gt;"[FILTERED]"}}}
  (0.3ms)  BEGIN
      User Exists (0.8ms)  SELECT  1 AS one FROM "users" WHERE "users"."email" = $1 LIMIT $2  [["email", "user@example.com"], ["LIMIT", 1]]
  (0.3ms) ROLLBACK 
      Completed 200 OK in 143ms (Views: 0.1ms | ActiveRecord: 1.4ms)
  </code></pre>