Jatin Ganhotra
Jatin Ganhotra

Reputation: 7035

File creation in rails + jquery

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 contents should be written to the file with the file extension specified by the user. How can I do so??

Upvotes: 0

Views: 63

Answers (1)

Nikita Rybak
Nikita Rybak

Reputation: 68006

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])
}

Upvotes: 1

Related Questions