Skip to content

Commit

Permalink
Adding instructions in readme; adding newlines at ends of files
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbechtel1 committed Oct 24, 2021
1 parent 91e56ba commit 099cef9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,13 @@ Which will generate the following SQL command:
COPY users (id, name) FROM '/tmp/users.dat' WITH BINARY
```

To specify the encoding with which to read the file, set the :encoding option.
This is useful for removing byte order marks when matching column headers.

```ruby
User.copy_from "/tmp/users_with_byte_order_mark.csv", :encoding => 'bom|utf-8'
```


### Using the CSV Responder
If you want to make the result of a COPY command available to download this gem provides a CSV responder that, in conjunction with [inherited_resources](https://github.com/josevalim/inherited_resources), is a very powerfull tool. BTW, do not try to use the responder without inherited_resources.
Expand Down
2 changes: 1 addition & 1 deletion spec/copy_from_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,4 @@
TestModel.order(:id).map{|r| r.attributes}.should == [{'id' => 1, 'data' => 'test data 1'}]
end

end
end
2 changes: 1 addition & 1 deletion spec/fixtures/comma_with_bom.csv
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
id,data
1,"test data 1"
1,"test data 1"

0 comments on commit 099cef9

Please sign in to comment.