AR Model Initialization Notes
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 Model.new 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 = SomethingElse.new(self)
@foo = 'bar'
end
0 comments