# Rails 2.3.2.1 ActiveResource objects are frozen?

**URL:** <https://www.ruby-forum.com/t/rails-2-3-2-1-activeresource-objects-are-frozen/168103>\
**Category:** Rails\
**Created:** [May 15, 2009, 9:56pm UTC](https://www.ruby-forum.com/t/rails-2-3-2-1-activeresource-objects-are-frozen/168103 "2009-05-15T21:56:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthewmurcia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7cd45c/32.png) [@matthewmurcia](https://www.ruby-forum.com/u/matthewmurcia)\
**Post date:** [May 15, 2009, 9:56pm UTC](https://www.ruby-forum.com/t/rails-2-3-2-1-activeresource-objects-are-frozen/168103/1 "2009-05-15T21:56:36Z")

</div>

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](http://madhatted.com)

---

<div class="post-metadata">

**Author:** ![matthewmurcia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7cd45c/32.png) [@matthewmurcia](https://www.ruby-forum.com/u/matthewmurcia)\
**Post date:** [May 15, 2009, 10:12pm UTC](https://www.ruby-forum.com/t/rails-2-3-2-1-activeresource-objects-are-frozen/168103/2 "2009-05-15T22:12:24Z")

</div>

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](http://madhatted.com)

---

<div class="post-metadata">

**Author:** ![matthewmurcia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7cd45c/32.png) [@matthewmurcia](https://www.ruby-forum.com/u/matthewmurcia)\
**Post date:** [May 15, 2009, 11:04pm UTC](https://www.ruby-forum.com/t/rails-2-3-2-1-activeresource-objects-are-frozen/168103/3 "2009-05-15T23:04:36Z")

</div>

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:

> <https://github.com/rails/rails/commit/5de340e79f1d11973b7c7bbec82f320fc92b9c99>

Can’t set the cache.

–  
Matthew B. :: 607 227 0871  
Resume & Portfolio @ [http://madhatted.com](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](http://madhatted.com)

---

<div class="post-metadata">

**Author:** ![matthewmurcia](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/7cd45c/32.png) [@matthewmurcia](https://www.ruby-forum.com/u/matthewmurcia)\
**Post date:** [May 16, 2009, 12:38am UTC](https://www.ruby-forum.com/t/rails-2-3-2-1-activeresource-objects-are-frozen/168103/4 "2009-05-16T00:38:59Z")

</div>

Ended up with this:

[https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/2655-railscache-freezes-all-objects-passed-to-it](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](http://madhatted.com)
