After_initialize isn't being called on AR object

All,

I have the following AR object:

class UploadedFile < ActiveRecord::Base

protected
def after_initialize
self.path = ‘abc’
end
end

When I call UploadedFile.new 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 = UploadedFile.new(:name => “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?

Wes

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