Hi,
I have this:
class Bullet < ActiveRecord::Base
include StagedVersionMethods
...
end
And this
module StagedVersionMethods
def initialize
puts self.bullet_id
end
end
When I create an instance of Bullet, the modules initialize method fires, but I get an ActiveRecord error: ...activerecord-2.2.2/lib/active_record/attribute_methods.rb:268:in `read_attribute'
My intent is to initialize an instance variable for which I need the primary key value of the record I'm mixing into. Other methods in the module will then work with this instance variable.
The module included() callback does not fit the task either, because self, in that context, is the Module not the AR record.
How should this be approached?
Thanks