title: Rails object saves, but doesn't persist?
body: <p>I have a Rails application for studying flashcards. It worked fine for months, then recently I made some slight changes while creating an API for a mobile app to work on top of it, and now the object no longer persists in the database (for reasons that should have nothing to do with the API).</p>
  
  <p>The controller code is as follows:</p>
  
  <pre><code>flashcard.process_card_study(params['ease'].to_i)
  debugger
  flashcard.save!
  </code></pre>
  
  <p><code>process_card_study</code> is a model method that changes the attributes according to the user's response. That still works fine - when I check the object with the debugger, the attributes have been changed appropriately. Then I run the next line of code to save it, and everything seems to work:</p>
  
  <p><code>(0.8ms)  BEGIN
   SQL (1.6ms)  UPDATE "flashcards" SET "repetition_streak" = $1, "next_study_date" = $2, "times_studied" = $3, "last_recall_quality" = $4, "last_study_date" = $5, "updated_at" = $6 WHERE "flashcards"."id" = $7  [["repetition_streak", 0], ["next_study_date", "2018-01-26 00:00:00"], ["times_studied", 1], ["last_recall_quality", 4], ["last_study_date", "2018-01-26 00:00:00"], ["updated_at", "2018-01-26 18:48:42.307211"], ["id", 200]]
     (2.4ms)  COMMIT</code></p>
  
  <p>I then check if the object still has the correct attributes (in the debugger still), and it does. however, when I come out of the debugger, the object is back to its original state!!</p>
  
  <p>The only callbacks I have on the object is an after_initialize, which sets all the values back to the initial state. This seems like it could be a culprit, although if the callback was run, the values would be reset in the debugger too, which they aren't. What's more, I was under the impression that a save call would not run an after_initialize callback.</p>
  
  <p>Any help or pushes in the right direction would be much appreciated.
  Michael</p>