how can i add download functionality

Hello friends

i have to generate a text file when clicked on a button and when this file got generated than i have to show a download dialog box so that user can download this text file on his computer, can any body gives any snippet of code or any idea how can i add this download functionality.

Thanks

your download dialog should simply link to an action that uses send_file to send the text file:

send_file(File.join(FILE_PATH, file_name), :filename => 'something.txt', :disposition => 'attachment', :type => 'text/plain'

Thorsten Mueller wrote:

your download dialog should simply link to an action that uses send_file to send the text file:

send_file(File.join(FILE_PATH, file_name), :filename => 'something.txt', :disposition => 'attachment', :type => 'text/plain'

Hello friend, Thanks for your help but it is not working for me , instead of the download dialog box its just showing me the content of the text file. can u give me any idea why this is happening.. ?

Thanks