Hi,
I have a plugin. in which there is a module.
In the init of the plugin I have a statement like
#ActiveRecord::Base.send (:include, Module::Plugin)
Thing.send (:include, Module::Plugin)
#Thing is a model
That however does not work.. and while debugging I find that any call
inside the Thing instance methods (rails development mode) returns a
method not found..However the same works when I use the script/
console..
Is there some rails quirk here? The include inside the
ActiveRecord::Base works but I dont want to include the module all
over..
That however does not work.. and while debugging I find that any call
inside the Thing instance methods (rails development mode) returns a
method not found..However the same works when I use the script/
console..
Is there some rails quirk here? The include inside the
ActiveRecord::Base works but I dont want to include the module all
over..
Take a look at rails initializers.. your Thing model is not loaded at
the time your plugins are loaded..
In development, after requests your model gets reloaded, and the
reloaded copy never has include called on it. One way of circumventing
things is for the model to request all this itself, with the fairly
common pattern
Thanks..but where do I add the config.to_prepare code? Or should I
just wrap the code in the plugin/init.rb within the config.to_prepare?
If yes,does it delay this till the Thing module is loaded or does it
forcibly load the Thing module?