From 239c96039b7fbea8284b2c0131ec5ee566891d5d Mon Sep 17 00:00:00 2001 From: Rory McCune Date: Thu, 22 May 2014 19:31:33 +0100 Subject: [PATCH] Update benefits.rb accept binary file types. The modification allows binary file types (e.g. MS word docs) to be uploaded without encountering encoding errors --- app/models/benefits.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/benefits.rb b/app/models/benefits.rb index 44a467d..5764c9d 100644 --- a/app/models/benefits.rb +++ b/app/models/benefits.rb @@ -4,7 +4,7 @@ class Benefits < ActiveRecord::Base def self.save(file, backup=false) data_path = Rails.root.join("public", "data") full_file_name = "#{data_path}/#{file.original_filename}" - f = File.open(full_file_name, "w+") + f = File.open(full_file_name, "wb+") f.write file.read f.close make_backup(file, data_path, full_file_name) if backup == "true"