ActiveRecord to_xml includes


#1

Guys

Supposing I have three models

Company has_many :people
Person has_many :addresses

Shouldn’t this work? a_company.to_xml(:include => {:people
=> :addresses})

I get this exception:

TypeError: can’t convert Symbol into Hash
from /Users/rodrigo/Documents/Work/Wellknown/Webapp/vendor/rails/
activerecord/lib/active_record/serialization.rb:66:in merge' from /Users/rodrigo/Documents/Work/Wellknown/Webapp/vendor/rails/ activerecord/lib/active_record/serialization.rb:66:inadd_includes’
from /Users/rodrigo/Documents/Work/Wellknown/Webapp/vendor/rails/
activerecord/lib/active_record/serialization.rb:56:in each' from /Users/rodrigo/Documents/Work/Wellknown/Webapp/vendor/rails/ activerecord/lib/active_record/serialization.rb:56:inadd_includes’
from /Users/rodrigo/Documents/Work/Wellknown/Webapp/vendor/rails/
activerecord/lib/active_record/serializers/xml_serializer.rb:267:in
serialize' from /opt/local/lib/ruby/gems/1.8/gems/builder-2.1.2/lib/builder/ xmlbase.rb:134:incall’
from /opt/local/lib/ruby/gems/1.8/gems/builder-2.1.2/lib/builder/
xmlbase.rb:134:in _nested_structures' from /opt/local/lib/ruby/gems/1.8/gems/builder-2.1.2/lib/builder/ xmlbase.rb:58:inmethod_missing’
from /opt/local/lib/ruby/gems/1.8/gems/builder-2.1.2/lib/builder/
xmlbase.rb:31:in tag!' from /Users/rodrigo/Documents/Work/Wellknown/Webapp/vendor/rails/ activerecord/lib/active_record/serializers/xml_serializer.rb:264:inserialize’
from /Users/rodrigo/Documents/Work/Wellknown/Webapp/vendor/rails/
activerecord/lib/active_record/serialization.rb:93:in to_s' from /Users/rodrigo/Documents/Work/Wellknown/Webapp/vendor/rails/ activerecord/lib/active_record/serializers/xml_serializer.rb:156:into_xml’
from (irb):23

Any ideas?

Thanks