Wednesday 15 July 2015

ruby - Change naming schema of first level associations in to_xml (ActiveRecord::Serialization) -



ruby - Change naming schema of first level associations in to_xml (ActiveRecord::Serialization) -

activerecord's to_xml serialization lets include first level assocations (with :include), alter naming convention (by :dasherize or :camelize). putting 2 looks this:

firm.to_xml :dasherize => false, include: :account

this changes naming convention on firm's fields, , not account's. i've tried following, throws syntax errors:

firm.to_xml :dasherize => false, include: :account {:dasherize => false} firm.to_xml :dasherize => false, include: {:account {:dasherize => false}}

if you're using ruby 1.9.x or above:

firm.to_xml dasherize: false, include: { account: { dasherize: false } }

ruby rails-activerecord

No comments:

Post a Comment