I'm building a website using Rails and I have a Model with some text type value store in MySQL database, I need to provide a download link for my users to download a "*.txt" file which contains those texts.
我正在使用Rails构建一个网站,我在MySQL数据库中有一个带有一些文本类型值存储的模型,我需要为我的用户提供下载链接以下载包含这些文本的“* .txt”文件。
what I've tried is to use render :text => my_text
but it's kind of ugly and the browser can't start a download .
我试过的是使用render:text => my_text但它有点难看,浏览器无法启动下载。
Not I'm trying to use CarrierWave and mount a output_file to my model , I want to build a method to generate a file from its text value. Any suggestion would be greatly appreciated. Thanks!
不是我正在尝试使用CarrierWave并将output_file挂载到我的模型,我想构建一个方法来从其文本值生成文件。任何建议将不胜感激。谢谢!