Rails: POST request with send_data response (or alternative)
<p>I am trying to make a POST endpoint that accepts a hash that will generate a two-line CSV (headers and one row of values), and return the CSV:</p>

<pre><code>  def generate
    csv = CSV.generate do |csv|
      csv &lt;&lt; csv_params[:data].keys
      csv &lt;&lt; csv_params[:data].values
    end

    send_data(csv, filename: 'testing.csv', disposition: 'attachment', type: :csv)
  end
</code></pre>

<p>The problem, it seems, is that browsers are not consistent with their support for POSTs returning attachments.</p>

<p>If I switch the <code>generate</code> action to a GET request, and works in all browsers. But my problem is that it would be possible to run into a URL size limit if I use GET and pass all the params in via the URL.</p>

<p>Is there something I'm missing with my POST implementation that uses <code>send_file</code>, or is there some trick I could use where I do not have to create a temporary file on the server, and return a reference to that file instead?</p>