Harsh Gupta
2014-Feb-19 20:24 UTC
Extending a module to models causes ArgumentError A copy of xx has been removed from module tree
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
deleted?
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.
class Samples
...
end
module LoadSamples
attr_accessor :samples
def load_samples
@samples ||= Samples.new
...
end
end
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?
This is my first post and I have a feeling that when I post this, it may
not appear as formatted. Please help me with the same too.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/95e268e2177e90a02b622dba6207d976%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.
Maybe Matching Threads
- A copy of XX has been removed from the module tree but is still active!
- config.cache_classes true or false in test environment?
- Want to Move RestfulAuthentication's UsersController to Admin::UsersController
- Help: A copy of ModelSecurity has been removed from the module tree but is still active!
- Weird active record problem - goes away with cache_classes change
