Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
namespace :data do
desc "Split the user's fullname into first and last names"
task :split_fullname => :environment do
User.reset_column_information
User.find_each do |user|
first_name, last_name = user.full_name.split ''
user.first_name = first_name
user.last_name = last_name
user.save!
end
end
end
class AddFirstNameAndLastNameToUsers < ActiveRecord::Migration
def change
add_column :users, :first_name, :string
add_column :users, :last_name, :string
end
end
class RemoveFullNameFromUsers < ActiveRecord::Migration
def change
remove_column :users, :full_name
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment