Lester Peabody
Lester Peabody

Reputation: 1888

Rails 3 file download wizard

I wrote an app that takes you through a 2 step wizard - one page collects information, the other is an agreement. When you click Agree the page loads a "Downloading this file..." page, and then should start actually downloading the file, overall a pretty common task. However, I'm struggling with a solution in Rails. Ideally I would think to just render the "Downloading page..." and then make a call to send_file, but you can't do this as it results in a DoulbeRender error.

What is a good way to load a page and then subsequently initiate a file download in Rails?

Upvotes: 0

Views: 292

Answers (1)

muffinista
muffinista

Reputation: 6736

You want to render the download page, and then send the user to a separate action which sends your file. Generally this is accomplished with a meta tag, see Trigger file download on a page with content for a PHP example.

Upvotes: 1

Related Questions