Skip to content

Instantly share code, notes, and snippets.

@JEG2
Created October 26, 2011 20:25
Show Gist options
  • Save JEG2/1317705 to your computer and use it in GitHub Desktop.
Save JEG2/1317705 to your computer and use it in GitHub Desktop.
class ExampleMigration < ActiveRecord::Migration
class MyModel < ActiveRecord::Base
def some_method_i_need
# ...
end
end
def self.up
add_column :my_models, :whatever, :string
MyModel.find_each do |my_model|
my_model.whatever = my_model.some_method_i_need
my_model.save!
end
end
def self.down
remove_column :my_models, :whatever
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment