cache_fu has a method for handling this type of issue which has been  
adapted for Rails.cache here:

http://github.com/actsasflinn/snippy/blob/77bdc5760180a5b5a8652af6dc6b1e3ecebbd99f/vendor/plugins/cache_contrib/lib/active_support/cache/patches/auto_load_missing_constants.rb

It's not really a bug per se, just a limitation in that un-marshaling  
doesn't autoload.  It'd be nice to see Rails.cache support this type  
of behavior though.


On Jan 25, 2009, at 3:44 PM, ara.t.howard wrote:

>
>
> i'm seeing issues with how caching interacts with auto const loading
> in production.  it's find if the objects cached are top-level
> themselves, but an object graph (model + associations) is cached i'll
> get errors when a production process first comes up (no models loaded)
> and hits the cache to get said object graph.
>
> this fix, which is a uber hack, shows quite clearly the bug - i'm
> *really* curious if anyone else has seen this behaviour
>
> the hack:
>
> vendor/rails/activesupport/lib/active_support/cache/mem_cache_store.rb
>
>
>  24       def read(key, options = nil)
>  25         super
>  26         @data.get(key, raw?(options))
>  27       rescue MemCache::MemCacheError => e
>  28         logger.error("MemCacheError (#{e}): #{e.message}")
>  29         nil
>  30       rescue ArgumentError => e
>  31         message = e.message
>  32         raise unless message =~ %r|undefined class/module|
>  33         class_name = message.scan(%r/\w+/).last
>  34         begin
>  35           ActiveSupport::Dependencies.load_missing_constant
> ActiveRecord::Base, class_name
>  36         rescue Object
>  37           raise e
>  38         end
>  39       end
>
>
> in case it isn't obvious this simply shows that rails const loading
> mechanism is not triggered from a Marshal.load, which makese sense
> actually....
>
> thoughts?
>
> a @ http://codeforpeople.com/
> --
> we can deny everything, except that we have the possibility of being
> better. simply reflect on that.
> h.h. the 14th dalai lama
>
>
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to