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? --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 Koebbe <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> 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 > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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. On Jun 24, 3:28 pm, Robert Walker <r0b3rt4...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 Koebbe <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: > > > 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 > > -- > > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---