mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Encode records with special chars as well
Using Marshal.dump on the French production database raised an error:
Encoding::UndefinedConversionError: "\xC3" from ASCII-8BIT to UTF-8
Replacing Marshal with YAML solves the problem. It is also more reliable
and human readable.
This code was run against the French, Australian and UK production
data successfully.
This commit is contained in:
@@ -29,11 +29,11 @@ class AssociateCustomersToUsers < ActiveRecord::Migration
|
||||
joins("INNER JOIN spree_users ON customers.email = spree_users.email").
|
||||
where(user_id: nil).all
|
||||
|
||||
File.write(backup_file, Marshal.dump(customers))
|
||||
File.write(backup_file, YAML.dump(customers))
|
||||
end
|
||||
|
||||
def backed_up_customers
|
||||
Marshal.load(File.read(backup_file))
|
||||
YAML.load(File.read(backup_file))
|
||||
end
|
||||
|
||||
def backup_file
|
||||
|
||||
Reference in New Issue
Block a user