zerosum dirt(nap)

evolution through a series of accidents

zerosum dirt(nap)

AR Model Initialization Notes

March 16, 2007 by nap · Comments

If you’re new to Rails but not to Ruby, you might be surprised to learn that Rails doesn’t use the standard Ruby initialize() method when is invoked or when a model instance is returned from a find.

If you need to add some initialization code to an ActiveRecord model, use the after_initialze callback instead:

def after_initialize
  @thing =
  @foo = 'bar'
blog comments powered by Disqus