ruby on rails - How to change the response format depending on the data sent? -


I'm doing some controller to submit reports and this is my problem:

User A Allows to download the open page with a form that changes the format of the download format and the date of the report.

A selected input is set to the download format.

When the user presses the button I want to respond based on the selected format.

The problem is that this is a specified trough url, then trying to do something like this:

  The case format when "xlsx" then format.xlsx {... } When "html" then format.html {...} ... end   

does not work because the rail or browser (I'm not sure) is expected to have an HTML response.

Although I have two options:

  1. Change the URL of the form onsubmit which creates a more dependent application on Javascript. Or

  2. redirect_to url + ". # {Params [: download_format]}"

    In other ways I feel better but I have to pass : report_date in the url and I can not find a way to do this.

    I have tried this:

      url = my_custom_url_path redirect_to url + ". # {Params [: download_format]}",: date_format => Params [: date_format]   

    but it is not working.

    In this form:

      & lt;% = f. Select: download_format, {"xlsx" = & gt; "Xlsx", "online" = & gt; "Html"}%>   

    In the controller:

      def operation if download_format = params [: download_format] .delete redirect_to my_action_path (options.merge (: format = & gt; download_format )) And the end of the withdrawal # Some arguments give feedback here- format | Format.xlsx {...} format.html {...} end end    

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -