How to send format for respond_to using post?

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?

Szymon Nowak 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

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 ]).

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.