I want to give users the option of uploading files in my Ruby on Rails 3.2 application, with the data going into the db. I wanted to use the COPY FROM
command s
You can use the gem https://github.com/diogob/postgres-copy
Assuming data
is an IO object.
User.copy_from data, columns: [:name, :taxon_id, :updated_at, :created_at]
Or using the path to the uploaded file directly:
User.copy_from "/tmp/uploaded_file.csv", columns: [:name, :taxon_id, :updated_at, :created_at]