Reputation: 889
ActiveRecord's to_xml serialization lets you include first level assocations (with :include), as well as change the naming convention (by :dasherize or :camelize). Putting the two together looks like this:
firm.to_xml :dasherize => false, include: :account
This only changes the naming convention on firm's fields, and not account's. I've tried the following, which throws back syntax errors:
firm.to_xml :dasherize => false, include: :account {:dasherize => false}
firm.to_xml :dasherize => false, include: {:account {:dasherize => false}}
Upvotes: 0
Views: 35
Reputation: 894
If you're using Ruby 1.9.x or above:
firm.to_xml dasherize: false, include: { account: { dasherize: false } }
Upvotes: 1
Reputation: 889
The correct syntax is
firm.to_xml :dasherize => false, include: {:account => {:dasherize => false}}
Upvotes: 0