Today, I was helping a newbie at work deal with a problem with a double render issue due to using send_data to generate a CSV.
We wanted to fill in a form and generate a CSV based on the parameters. Once the CSV was downloaded, we want to stay on the form and allow them to redo everything and generate a new CSV.
The problem with this in Rails is two-fold;
I think it’s important when dealing with new programmers to admit when you don’t know the answer and help them down the rabbit holes that ensue.
I feel like this should be a more common problem with an elegant solutions already.
We solved this problem by making the form submit a remote request, which then perform a bit of a hack to make another request which handles the send_data aspect of our request …
<% date = { this: "that", that: "the other" }.to_query %>
window.open("/another_action?<%= data %>", target: "_blank");
Urgh.