Hey all, I''ve dug through the code and bit and cannot figure out how or why this is, but between Rails 2.1 and 2.3.2.1 production ActiveResource objects became frozen upon retrieval. so: ------------------- class Resource < ActiveRecource::Base def my_thing @my_thing ||= Finder.find_by_something( self.a_thing ) end end @resource = Resource.find_by_id( a_number ) @resource.frozen? #=> true @resource.my_thing #=> TypeError: can''t modify frozen object --------------------- In 2.1 returned objects were not frozen, and in 2.3.2.1''s development mode they are not. Disabling caches didn''t help. Is it something from the LibXML/Nokogiri move? Anyone else using ActiveResource on 2.3.2.1? -- Matthew Beale :: 607 227 0871 Resume & Portfolio @ http://madhatted.com
Shoot, it looks like we have some Rails.cache being called. I think I noticed objects pulled out of memcache being frozen. Is there a reason? Who knows. On Fri, 2009-05-15 at 15:54 -0400, Matthew Beale wrote:> Hey all, > > I''ve dug through the code and bit and cannot figure out how or why this > is, but between Rails 2.1 and 2.3.2.1 production ActiveResource objects > became frozen upon retrieval. > > so: > > ------------------- > class Resource < ActiveRecource::Base > > def my_thing > @my_thing ||= Finder.find_by_something( self.a_thing ) > end > > end > > @resource = Resource.find_by_id( a_number ) > @resource.frozen? #=> true > @resource.my_thing #=> TypeError: can''t modify frozen object > --------------------- > > In 2.1 returned objects were not frozen, and in 2.3.2.1''s development > mode they are not. Disabling caches didn''t help. > > Is it something from the LibXML/Nokogiri move? Anyone else using > ActiveResource on 2.3.2.1? >-- Matthew Beale :: 607 227 0871 Resume & Portfolio @ http://madhatted.com
Matthew Beale
2009-May-15 21:03 UTC
Re: Rails 2.3.2.1 ActiveResource objects are frozen? <- Cannot configure cache
Uh, now I just can''t configure the cache: ------------------------->> Rails.cache=> #<ActiveSupport::Cache::MemoryStore:0xb6f3fd98 @data={}>>> ActionController::Base.cache_store = :mem_cache_store, ''localhost:11211''=> [:mem_cache_store, "localhost:11211"]>> Rails.cache=> #<ActiveSupport::Cache::MemoryStore:0xb6f3fd98 @data={}> ------------------------ So my cache calls all hit memory_store, so I get frozen exceptions from this (perfectly valid) commit: http://github.com/rails/rails/commit/5de340e79f1d11973b7c7bbec82f320fc92b9c99 Can''t set the cache. -- Matthew Beale :: 607 227 0871 Resume & Portfolio @ http://madhatted.com On Fri, 2009-05-15 at 16:10 -0400, Matthew Beale wrote:> Shoot, it looks like we have some Rails.cache being called. I think I > noticed objects pulled out of memcache being frozen. Is there a reason? > Who knows. > > On Fri, 2009-05-15 at 15:54 -0400, Matthew Beale wrote: > > Hey all, > > > > I''ve dug through the code and bit and cannot figure out how or why this > > is, but between Rails 2.1 and 2.3.2.1 production ActiveResource objects > > became frozen upon retrieval. > > > > so: > > > > ------------------- > > class Resource < ActiveRecource::Base > > > > def my_thing > > @my_thing ||= Finder.find_by_something( self.a_thing ) > > end > > > > end > > > > @resource = Resource.find_by_id( a_number ) > > @resource.frozen? #=> true > > @resource.my_thing #=> TypeError: can''t modify frozen object > > --------------------- > > > > In 2.1 returned objects were not frozen, and in 2.3.2.1''s development > > mode they are not. Disabling caches didn''t help. > > > > Is it something from the LibXML/Nokogiri move? Anyone else using > > ActiveResource on 2.3.2.1? > >-- Matthew Beale :: 607 227 0871 Resume & Portfolio @ http://madhatted.com
Matthew Beale
2009-May-15 22:37 UTC
Re: Rails 2.3.2.1 ActiveResource objects are frozen? <- Cannot configure cache
Ended up with this: https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/2655-railscache-freezes-all-objects-passed-to-it Anything written to any cache will be frozen. Bug at the worst, REALLY unexpected at the best. -- Matthew Beale :: 607 227 0871 Resume & Portfolio @ http://madhatted.com On Fri, 2009-05-15 at 17:03 -0400, Matthew Beale wrote:> Uh, now I just can''t configure the cache: > > ------------------------- > >> Rails.cache > => #<ActiveSupport::Cache::MemoryStore:0xb6f3fd98 @data={}> > >> ActionController::Base.cache_store = :mem_cache_store, ''localhost:11211'' > => [:mem_cache_store, "localhost:11211"] > >> Rails.cache > => #<ActiveSupport::Cache::MemoryStore:0xb6f3fd98 @data={}> > ------------------------ > > So my cache calls all hit memory_store, so I get frozen exceptions from > this (perfectly valid) commit: > > http://github.com/rails/rails/commit/5de340e79f1d11973b7c7bbec82f320fc92b9c99 > > Can''t set the cache. > > -- > Matthew Beale :: 607 227 0871 > Resume & Portfolio @ http://madhatted.com > > > On Fri, 2009-05-15 at 16:10 -0400, Matthew Beale wrote: > > Shoot, it looks like we have some Rails.cache being called. I think I > > noticed objects pulled out of memcache being frozen. Is there a reason? > > Who knows. > > > > On Fri, 2009-05-15 at 15:54 -0400, Matthew Beale wrote: > > > Hey all, > > > > > > I''ve dug through the code and bit and cannot figure out how or why this > > > is, but between Rails 2.1 and 2.3.2.1 production ActiveResource objects > > > became frozen upon retrieval. > > > > > > so: > > > > > > ------------------- > > > class Resource < ActiveRecource::Base > > > > > > def my_thing > > > @my_thing ||= Finder.find_by_something( self.a_thing ) > > > end > > > > > > end > > > > > > @resource = Resource.find_by_id( a_number ) > > > @resource.frozen? #=> true > > > @resource.my_thing #=> TypeError: can''t modify frozen object > > > --------------------- > > > > > > In 2.1 returned objects were not frozen, and in 2.3.2.1''s development > > > mode they are not. Disabling caches didn''t help. > > > > > > Is it something from the LibXML/Nokogiri move? Anyone else using > > > ActiveResource on 2.3.2.1? > > >