开发者

File creation in rails + jquery

开发者 https://www.devze.com 2023-01-10 00:41 出处:网络
I am new to Rails. In my web application, the user can type the contents of a file in a textarea or a content Editable iFrame and when he saves the file, the con开发者_开发知识库tents should be writte

I am new to Rails. In my web application, the user can type the contents of a file in a textarea or a content Editable iFrame and when he saves the file, the con开发者_开发知识库tents should be written to the file with the file extension specified by the user. How can I do so??


Where're you having a problem? Saving a file in ruby is easy. Something like this should work, assuming you have parameters file_type and text.

File.open("myfile.#{params[:file_type]}", 'w') { |f|
  f.write(params[:text])
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号