How can I extend a module to a model class and use an instance of a
custom class as a class instance variable for model such that when next
request comes, custom class could be found and older instances are
I created a class Samples. I also created a module LoadSamples where
in a method say load_samples, I create a new Samples instance and
assign it to a class instance variable. I extend LoadSamples to
ActiveRecord::Base and called load_samples from model User.
@samples ||= Samples.new
The first page that loads, loads fine, but subsequent request gives:
ArgumentError in UsersController#new
A copy of BaseSample::LoadSamples has been removed from the module tree
but is still active!
and points to line @samples ||= Samples.new
This works in production mode or when I set config.cache_classes to
true. But it becomes difficult to work in dev mode.
What can I do about it and what are the alternatives?