From 92a03d888e0053962061fdfb1139c91e086bff0e Mon Sep 17 00:00:00 2001 From: Brendon Muir Date: Fri, 16 Aug 2013 14:10:31 +1200 Subject: Use binary mode to write uploaded files [ci skip] See: http://stackoverflow.com/a/4988984/129798 for an explanation for why this is required for Ruby 1.9. --- guides/source/form_helpers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guides/source') diff --git a/guides/source/form_helpers.md b/guides/source/form_helpers.md index 11e8db9e88..3a18fb81d8 100644 --- a/guides/source/form_helpers.md +++ b/guides/source/form_helpers.md @@ -605,7 +605,7 @@ The object in the `params` hash is an instance of a subclass of IO. Depending on ```ruby def upload uploaded_io = params[:person][:picture] - File.open(Rails.root.join('public', 'uploads', uploaded_io.original_filename), 'w') do |file| + File.open(Rails.root.join('public', 'uploads', uploaded_io.original_filename), 'wb') do |file| file.write(uploaded_io.read) end end -- cgit v1.2.3