# How to send format for respond\_to using post?

**URL:** <https://www.ruby-forum.com/t/how-to-send-format-for-respond-to-using-post/141290>\
**Category:** Rails\
**Created:** [June 24, 2008, 11:57am UTC](https://www.ruby-forum.com/t/how-to-send-format-for-respond-to-using-post/141290 "2008-06-24T11:57:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [June 24, 2008, 11:57am UTC](https://www.ruby-forum.com/t/how-to-send-format-for-respond-to-using-post/141290/1 "2008-06-24T11:57:53Z")

</div>

Hi,

I’m generating reports in various format (html, text, pdf etc) and  
currently I’m using formatted\_foo\_path(@foo, :format) to get a report  
in specific format. However, I’d like to provide users a choice of  
format through simple select box. How to do it?

I could use javascript to change extension of the form action url, but  
is there non-javascript solution?

---

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [June 24, 2008, 12:52pm UTC](https://www.ruby-forum.com/t/how-to-send-format-for-respond-to-using-post/141290/2 "2008-06-24T12:52:33Z")

</div>

Szymon N. wrote:

> Hi,
> 
> I’m generating reports in various format (html, text, pdf etc) and  
> currently I’m using formatted\_foo\_path(@foo, :format) to get a report  
> in specific format. However, I’d like to provide users a choice of  
> format through simple select box. How to do it?
> 
> I could use javascript to change extension of the form action url, but  
> is there non-javascript solution?

I have not done what you are trying to accomplish, but I _think_ the  
format just comes in as a param. params[:format] I believe. If that is  
the case, you should be able to use a select and give it the html name  
‘format’.

Peace,  
Phillip

---

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [June 24, 2008, 9:28pm UTC](https://www.ruby-forum.com/t/how-to-send-format-for-respond-to-using-post/141290/3 "2008-06-24T21:28:58Z")

</div>

Just thinking out loud, but would it be possible to do something like:

formatted\_foo\_path(@foo, selected\_format.to\_sym)

where selected\_format is the value of the select field. (i.e. [ xml,  
html, csv, etc ]).

On Jun 24, 6:52 am, Phillip K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![g0nzo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/3bc359/32.png) [@g0nzo](https://www.ruby-forum.com/u/g0nzo)\
**Post date:** [June 24, 2008, 9:31pm UTC](https://www.ruby-forum.com/t/how-to-send-format-for-respond-to-using-post/141290/4 "2008-06-24T21:31:20Z")

</div>

But, on second thought I suppose it’s to late to do that for the form  
that is displayed. So scratch that previous post. Maybe javascript is  
your only plausible route.
