AR after_initialize quandry

I have a case where I am abstracting the creation of models. After a fair bit of indirection, I eventually get around to making a .new call.

I need to be able to pass params to that .new call.

I know I can't use def initialize() in an AR model (rather frustrating).

So, I have found some references to after_initialize, but that doesn't work either.

I see several threads on people trying to use after_initialize, but no conclusive answers to the same errors I am seeing -- undefined method `stringify_keys!

Example refc: Purpose of after_initialize in ActiveRecord? - Rails - Ruby-Forum

My after_initialize is just this simple code:

def after_initialize(asset_path)   @asset_path = asset_path end

So either a) what is the proper technique for using after_initialize, or b) is there another way I can pass params to an AR model in a .new call ?

Thx.

-- greg willits

Greg Willits wrote: [...]

So either a) what is the proper technique for using after_initialize, or b) is there another way I can pass params to an AR model in a .new call ?

Can't you just call Model.new(:the => 'params', :go => 'here') ?

Thx.

-- greg willits

Best,

[...]

So either a) what is the proper technique for using after_initialize, or b) is there another way I can pass params to an AR model in a .new call ?

Can't you just call Model.new(:the => 'params', :go => 'here') ?

<smack> I've never used that form, but I should have remembered it.

For my immediate need that won't work, but that's a function of the domain problem in this instance (turns out what I wanted can't be solved by passing params into new anyway). For general purpose needs, that would probably work, so I'll implement it in the API for this abstrated system to at least support passsing attributes upon a new().

Thx.

-- gw