rails, activerecord callbacks not saving

Posted by Joseph Silvashy on Stack Overflow See other posts from Stack Overflow or by Joseph Silvashy
Published on 2010-05-08T19:42:04Z Indexed on 2010/05/08 19:48 UTC
Read the original article Hit count: 265

Filed under:

I have a model with a callback that runs after_update:

after_update :set_state

protected

def set_state
  if self.valid?
    self.state = 'complete'
  else
    self.state = 'in_progress'
  end
end  

But it doesn't actually save those values, why not? Regardless of if the model is valid or not it won't even write anything, even if i remove the if self.valid? condition, I can't seem to save the state.

Um, this might sound dumb, do I need to run save on it?

© Stack Overflow or respective owner

Related posts about ruby-on-rails