Skip to content

Instantly share code, notes, and snippets.

@mruhlin
Created July 10, 2015 17:09
Show Gist options
  • Save mruhlin/6ee8222c4c6da3d5bcc9 to your computer and use it in GitHub Desktop.
Save mruhlin/6ee8222c4c6da3d5bcc9 to your computer and use it in GitHub Desktop.
class NormalizeUserNames < ActiveRecord::Migration
def self.up
total_customers = Customer.count
Customer.all.each_with_index do |customer, index|
puts " [#{index + 1}/#{total_customers}] #{customer.subdomain}"
System.with_customer(customer) do
User.silo.each do |u|
u.first_name = u.first_name.strip
u.last_name = u.last_name.strip
u.save
end
end
end
puts "super admins"
User.where(customer_id:0) do |u|
u.first_name = u.first_name.strip
u.last_name = u.last_name.strip
u.save
end
end
def self.down
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment