i''m caching constant models in memory, but if i try something like @user.type = Rails.cache.read ''types/1'' i get: "ActiveRecord::AssociationTypeMismatch - Type(#39040660) expected, got Type(#29355550)" 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. ps: there is a thread with a similar problem at ''http://www.ruby-forum.com/topic/101817'' but their solution is not working for this rails version. -- 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Jun 24, 4:22 am, Pepe Junty <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> i''m caching constant models in memory, but if > i try something like > > @user.type = Rails.cache.read ''types/1'' > > i get: > > "ActiveRecord::AssociationTypeMismatch - Type(#39040660) > expected, got Type(#29355550)" > > 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. Fred> ps: there is a thread with a similar problem > at ''http://www.ruby-forum.com/topic/101817''but > their solution is not working for this rails > version. > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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?> 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. > > Fred-- 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Jun 24, 9:04 pm, Pepe Junty <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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). Fred> > 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. > > > Fred > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---