Rails 2.3.2.1 ActiveResource objects are frozen?

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 B. :: 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 B. wrote:

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 B. :: 607 227 0871
Resume & Portfolio @ http://madhatted.com

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:

Can’t set the cache.


Matthew B. :: 607 227 0871
Resume & Portfolio @ http://madhatted.com

On Fri, 2009-05-15 at 16:10 -0400, Matthew B. wrote:


Matthew B. :: 607 227 0871
Resume & Portfolio @ http://madhatted.com

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 B. :: 607 227 0871
Resume & Portfolio @ http://madhatted.com