excel - Rails send file xlsx didn't work -
i use axlsx generate excel, confused how let user download it.
i wrote in download controller, , excel file's path public/excel/timestamp.xlsx.
def code_generator if request.post? #generate xlsx...... excel_path = "#{rails.root}/public/excel/" + datetime.now.strftime('%q') + '.xlsx' send_file excel_path, :disposition => "attachment" end end
when post data controller, browser didn't create download action.
however, in terminal, displayed
2016-11-08 17:01:56.971 [info] sent file /users/username/desktop/project_name/public/excel/1478595716963.xlsx (0.1ms)
update
i found out there's nothing send_file
.
here original code
# code_generator.html.erb <%= form_tag('/admin/code_generator', method: 'post', remote: true) %>
i change
<%= form_tag('/admin/code_download') %>
add new controller method code_download
, same thing original code_generator
.
but time, works. i'm not sure, guess problem causes remote: true
?
Comments
Post a Comment