the class is the same, but the ids aren't, so rails
refuse the association. but if i enable class_cache,
like in production, everything goes well. so here
is the question: is there a way to work with this
kind of caching in development mode? thanks.
the class is the same, but the ids aren't, so rails
refuse the association. but if i enable class_cache,
like in production, everything goes well. so here
is the question: is there a way to work with this
kind of caching in development mode? thanks.
Not really. The problem is that after each request rails tears down
the classes it has loaded and guts them (and then unsets the
corresponding constant), so your cached object is of a class with no
methods etc... and distinct from the current Type class.
thanks for your answer, Fred. it's really a pain, do you know the
reason for that? wouldn't a simple class check be enough,
like in java?
The problem is that technically the two classes really are different.
The convenience of the automatic reloading does have some drawbacks.
If you can get your cache to be wiped at the end of the request cycle
(see config.to_prepare etc..., or mark the code handling the cache as
reloadable) then you would also be ok (but your cache would
effectively be wiped for each request).