code to reproduce
# any model where one of the fields is of type timestamp according to type_cast
me = Person.find(97196)
puts me.to_xml
error thrown
TypeError: can't modify frozen string
from /usr/local/lib/ruby/1.8/date/format.rb:105:in `chomp!'
from /usr/local/lib/ruby/1.8/date/format.rb:105:in `method_missing'
from /usr/local/lib/ruby/1.8/date/format.rb:963:in `_parse'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/schema_definitions.rb:114:in `string_to_time'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/schema_definitions.rb:61:in `type_cast'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1873:in `read_attribute'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/base.rb:1849:in `method_missing'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/xml_serialization.rb:291:in `send'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/xml_serialization.rb:291:in `compute_value'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/xml_serialization.rb:246:in `initialize'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/xml_serialization.rb:159:in `new'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/xml_serialization.rb:159:in `serializable_attributes'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/xml_serialization.rb:159:in `collect'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/xml_serialization.rb:159:in `serializable_attributes'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/xml_serialization.rb:168:in `add_attributes'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/xml_serialization.rb:231:in `to_s'
from /usr/local/lib/ruby/gems/1.8/gems/builder-2.1.1/lib/builder/xmlbase.rb:134:in `call'
from /usr/local/lib/ruby/gems/1.8/gems/builder-2.1.1/lib/builder/xmlbase.rb:134:in `_nested_structures'
from /usr/local/lib/ruby/gems/1.8/gems/builder-2.1.1/lib/builder/xmlbase.rb:58:in `method_missing'
from /usr/local/lib/ruby/gems/1.8/gems/builder-2.1.1/lib/builder/xmlbase.rb:31:in `__send__'
from /usr/local/lib/ruby/gems/1.8/gems/builder-2.1.1/lib/builder/xmlbase.rb:31:in `tag!'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/xml_serialization.rb:230:in `to_s'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/xml_serialization.rb:107:in `to_xml'
patch
--- lib/merb/core_ext/merb_symbol.rb (rev 227)
+++ lib/merb/core_ext/merb_symbol.rb (working copy)
# faster Symbol#to_s to speed up routing.
def to_s
- @str_rep ||= id2name.freeze
+ @str_rep ||= id2name
end
# ["foo", "bar"].map &:reverse #=> ['oof', 'rab']
my $0.02
I consider this a short term fix. I'll keep looking for a work around because fast routing (what that freeze was for) is a big feature of merb. I need xml representations of my models today so....