Forum: Ruby on Rails ActiveRecord to_xml includes

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.
Rodrigo K. (Guest)
on 2009-02-19 22:53
(Received via mailing list)
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:in `add_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:in `add_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:in `call'
  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:in `method_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:in
`serialize'
  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:in
`to_xml'
  from (irb):23


Any ideas?

Thanks
This topic is locked and can not be replied to.