Last active
December 17, 2015 06:19
-
-
Save delba/5564537 to your computer and use it in GitHub Desktop.
Uploading a file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DocumentsController < ApplicationController | |
| def create | |
| FileUtils.mv document.tempfile, upload_path | |
| end | |
| private | |
| def document | |
| params[:document] | |
| end | |
| def upload_path | |
| Rails.public_path.join('uploads', document.original_filename) | |
| end | |
| end | |
| =begin | |
| FileUtils.cp document.tempfile, upload_path | |
| File.open upload_path, 'wb' do |f| | |
| f.write document.read | |
| end | |
| =end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment