Skip to content

Instantly share code, notes, and snippets.

@delba
Last active December 17, 2015 06:19
Show Gist options
  • Select an option

  • Save delba/5564537 to your computer and use it in GitHub Desktop.

Select an option

Save delba/5564537 to your computer and use it in GitHub Desktop.
Uploading a file
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