0

I need do to simple loading of files to public folder. There are many gems, but all them (and tutorials) show how to do this using model etc... But i need simple chose file in view, and send it to controller, which generate random name and save it to public folder, without any model and so over. Simple chose - upload.

brabertaser19
  • 5,678
  • 16
  • 78
  • 184

1 Answers1

0

You can use carrier wave without active record, or

You can write manually to to public folder,you can read file using params[:file_name].tempfile it's rack multipart object you can inspect by putting debugger or pry

Amar
  • 6,874
  • 4
  • 25
  • 23
  • hm, could you write more detaily second variant (how to get via params i know), but how to write, generate name and save it? – brabertaser19 Sep 07 '12 at 09:04
  • you can open a file/fileutils with some random name,and read from tempfile and write content to open file – Amar Sep 07 '12 at 09:10
  • you can refer and if you want you can change code as per your need http://stackoverflow.com/questions/4704143/rails-3-get-raw-post-data-and-write-it-to-tmp-file – Amar Sep 10 '12 at 08:57
  • or http://stackoverflow.com/questions/6415895/uploading-a-raw-file-to-rails-using-carrierwave – Amar Sep 10 '12 at 08:59