Hey all, I''m trying to change the xml output from a dash to underscore: <updated-at type="datetime">2010-01-15T17:00:23Z</updated-at> to <updated_at type="datetime">2010-01-15T17:00:23Z</updated_at> Does anyone have any suggestions? Thanks. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi John, On Fri, 2010-01-15 at 20:36 +0100, John Merlino 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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Robert Walker
2010-Jan-15 19:58 UTC
Re: XML output generates dashes rather than underscore
John Merlino wrote:> Hey all, > > I''m trying to change the xml output from a dash to underscore: > > <updated-at type="datetime">2010-01-15T17:00:23Z</updated-at> > > 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 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Fri, 2010-01-15 at 20:36 +0100, John Merlino 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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.