After_initialize isn't being called on AR object


I have the following AR object:

class UploadedFile < ActiveRecord::Base

def after_initialize
self.path = ‘abc’

When I call and pass it a value for the “name”
attribute, I don’t see the path attribute get a value like I expect.

See (from script/console):

uf = => “xyz”)
=> #<UploadedFile id: nil, name: “xyz”, path: nil, created_at: nil,
updated_at: nil>

AFAIK, after_initialize is ok to use in Rails 2.1.

What am I doing wrong here?


Never mind.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs