Skip to content

Instantly share code, notes, and snippets.

@cfitz
Created March 22, 2018 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cfitz/0a2347ee24f13bf9bba2282f6e45fc36 to your computer and use it in GitHub Desktop.
Save cfitz/0a2347ee24f13bf9bba2282f6e45fc36 to your computer and use it in GitHub Desktop.
# plugins/local/backend/model/fix_sort_names.rb
[ NameCorporateEntity, NameFamily, NamePerson, NameSoftware].each do |klass|
$stderr.puts "Updating ... #{klass}"
klass.all.each do |obj|
# get the jsonmodel
json = klass.to_jsonmodel(obj)
# now "update" the record with a copy of its json
obj.update_from_json(json)
# refresh the object and split it out...
obj.refresh
$stderr.puts "#{obj.id} ==> #{obj.sort_name}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment