title: How to detect attribute changes from model?
body: <p>I'd like to create a callback function in rails that executes after a model is saved.</p>
  
  <p>I have this model, Claim that has a attribute 'status' which changes depending on the state of the claim, possible values are pending, endorsed, approved, rejected</p>
  
  <p>The database has 'state' with the default value of 'pending'.</p>
  
  <p>I'd like to perform certain tasks after the model is created on the first time or updated from one state to another, depending on which state it changes from.</p>
  
  <p>My idea is to have a function in the model:</p>
  
  <pre><code>    after_save :check_state
  
      def check_state
        # if status changed from nil to pending (created)
        do this
  
        # if status changed from pending to approved
        performthistask
       end
  </code></pre>
  
  <p>My question is how do I check for the previous value before the change within the model?</p>