Created
August 23, 2014 09:04
-
-
Save vinhnglx/a467d2c0f4379857e999 to your computer and use it in GitHub Desktop.
Nice tips about rails ref: http://qiita.com/vinhnguyenleasnet/items/b0d7133e295439042905
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AddNameToUser < ActiveRecord::Migration | |
def self.up | |
add_column :users, :name, :string | |
User.reset_column_information | |
User.find(:all).each do |user| | |
user.name = user.first_name + ' ' + user.last_name | |
end | |
remove_column :users, :first_name | |
remove_column :users, :last_name | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment