Skip to content

Setting to_xml :dasherize=>false doesn't apply to :included models #6958

Closed
anthonyalberto opened this Issue Jul 4, 2012 · 5 comments

3 participants

@anthonyalberto

Hello

Using Rails 3.2.6, calling model.to_xml(:dasherize=>false, :include=>:my_included_model), I get a xml with dasherized content for the included model.

The only way I could find to make it work was to override to_xml all together, but I guess there should be a way to let Rails know if we want to disable dasherizing of included models.

Thanks

@acapilleri

:dasherize => false also for : my_included_model could have sense.
cc / @rafaelfranca

@rafaelfranca
Ruby on Rails member

Yes,

model.to_xml(:dasherize=>false, :include=> { :my_included_model => { :dasherize=>false } })

should work.

@acapilleri thanks.

@anthonyalberto

Ok thanks for the clarification.

Otherwise, if you include lots of models, it quickly becomes ugly :)
Shouldn't it be the default? Or at least get another option, eg : model.to_xml(:dasherize_includes=>true, :include=>:my_included_model)?

It's no big deal, just my thought to make it clearer!

Thanks guys

@rafaelfranca
Ruby on Rails member

Well, I agree with you. If you want feel free to provide a pull request adding this feature.

I closed this issue since it is not a bug, but you can make feature requests in the Rails core mailing list of opening a pull request.

@anthonyalberto

OK thanks

@sgerrand sgerrand pushed a commit to sgerrand/rails that referenced this issue Nov 2, 2013
@anthonyalberto anthonyalberto Following the false issue reporting I did here : rails#6958
- Enable propagation of :skip_types, :dasherize and :camelize on included models by default
- Adding the option to override this propagation on a per-include basis (:include => { :model => { :dasherize => false } }
- Enough tests to prove it works
- Updated activemodel CHANGELOG.md

Squashed my commits
78f5874
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.