Forum: Ruby on Rails Rails 2.3.2.1 ActiveResource objects are frozen?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
39b36b2be47228f8619d61ea7a607a25?d=identicon&s=25 Matthew Beale (mixonic)
on 2009-05-15 21:56
(Received via mailing list)
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
39b36b2be47228f8619d61ea7a607a25?d=identicon&s=25 Matthew Beale (mixonic)
on 2009-05-15 22:12
(Received via mailing list)
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:
>
>
> 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
39b36b2be47228f8619d61ea7a607a25?d=identicon&s=25 Matthew Beale (mixonic)
on 2009-05-15 23:04
(Received via mailing list)
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/5de340e79f1d1...

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:
> >
> >
> >
--
Matthew Beale :: 607 227 0871
Resume & Portfolio @ http://madhatted.com
39b36b2be47228f8619d61ea7a607a25?d=identicon&s=25 Matthew Beale (mixonic)
on 2009-05-16 00:38
(Received via mailing list)
Ended up with this:

https://rails.lighthouseapp.com/projects/8994-ruby...

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
This topic is locked and can not be replied to.