Rails how to know when send_file

Since it takes some time to prepare the contents of the downloaded data, I want to show the message "Preparing the file for downloading" when the user sends a request

Then, when the file is ready, I use send_file to send the data

Once this is done, I need to clear the message

Thank you so much

+3
source share
1 answer

Here is what I will do.

1. Create a prepare_file action

Firstly, I would create an action whose task would be to simply create a file and not display HTML, it will display a JSON object with the name of the created file.

2. Use AJAX to invoke the prepare_file action

, , " ..." AJAX . , AJAX, - .

3.

, JavaScript . send_file .

, , . , . , , . , , , , , .

, , , , ​​ .

, , .

+5

Source: https://habr.com/ru/post/1762123/


All Articles