# How to use the same params in respond\_to for some formats?

**URL:** <https://www.ruby-forum.com/t/how-to-use-the-same-params-in-respond-to-for-some-formats/181214>\
**Category:** Ruby\
**Created:** [January 7, 2010, 1:27pm UTC](https://www.ruby-forum.com/t/how-to-use-the-same-params-in-respond-to-for-some-formats/181214 "2010-01-07T13:27:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![camilleroux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/4491bb/32.png) [@camilleroux](https://www.ruby-forum.com/u/camilleroux)\
**Post date:** [January 7, 2010, 1:27pm UTC](https://www.ruby-forum.com/t/how-to-use-the-same-params-in-respond-to-for-some-formats/181214/1 "2010-01-07T13:27:17Z")

</div>

Hello,

I want to make an API in XML and JSON (maybe more), and I want most of  
the time use the same parameters for the to\_xml and the to\_json (same  
:include, :only, :except, :methods).  
In your opinion, what is the best way to do that?

Thank you  
Camille R.

---

<div class="post-metadata">

**Author:** ![camilleroux](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/4491bb/32.png) [@camilleroux](https://www.ruby-forum.com/u/camilleroux)\
**Post date:** [January 7, 2010, 10:18pm UTC](https://www.ruby-forum.com/t/how-to-use-the-same-params-in-respond-to-for-some-formats/181214/2 "2010-01-07T22:18:47Z")

</div>

Camille R. wrote:

> I want to make an API in XML and JSON (maybe more), and I want most of  
> the time use the same parameters for the to\_xml and the to\_json (same  
> :include, :only, :except, :methods).  
> In your opinion, what is the best way to do that?

respond\_to is not a ruby method. My guess is that you are writing an  
application in Rails. Rails has its own forums and you would do best to  
ask there; this forums is for the Ruby programming language.
