XML output generates dashes rather than underscore

Hey all,

I’m trying to change the xml output from a dash to underscore:

2010-01-15T17:00:23Z

to

<updated_at type=“datetime”>2010-01-15T17:00:23Z</updated_at>

Does anyone have any suggestions? Thanks.

John M. wrote:

Hey all,

I’m trying to change the xml output from a dash to underscore:

2010-01-15T17:00:23Z

to

<updated_at type=“datetime”>2010-01-15T17:00:23Z</updated_at>

Does anyone have any suggestions? Thanks.

An excerpt from the Rails docs on to_xml:
http://www.railsbrain.com/api/rails-2.3.2/doc/index.html?a=M001926&name=to_xml

This behavior can be controlled with :only, :except, :skip_instruct,
:skip_types, :dasherize and :camelize . The :only and :except options
are the same as for the attributes method. The default is to dasherize
all column names, but you can disable this setting :dasherize to false.
Setting :camelize to true will camelize all column names - this also
overrides :dasherize. To not have the column type included in the XML
output set :skip_types to true.

@model.to_xml :dasherize => false

Hi John,

On Fri, 2010-01-15 at 20:36 +0100, John M. wrote:

I’m trying to change the xml output from a dash to underscore:

What are you using to generate the xml ? There are several options.

Best regards,
Bill

On Fri, 2010-01-15 at 20:36 +0100, John M. wrote:

I’m trying to change the xml output from a dash to underscore:

Just in case, if you’re using the to_xml method, add :dasherize => false
to the options.

HTH,
Bill

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs