Created
September 4, 2015 07:18
-
-
Save StefanWallin/060101ae95eff0c53eda to your computer and use it in GitHub Desktop.
AddFlagsToHuman
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 AddFlagsToHuman < ActiveRecord::Migration | |
def change | |
# Add the flags | |
add_column :humen, :signed_up, :boolean, default: false | |
add_column :humen, :welcome_email_sent, :boolean, default: false | |
# Set the flags values | |
reversible do |dir| | |
dir.up do | |
Humen.all.select(&:signed_up?).each do |human| | |
human.update(signed_up: true, welcome_email_sent: true) | |
end | |
end | |
end | |
end | |
def signed_up? | |
# Todo: copy from code | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
current method relied on the existance of certain methods plus putting private methods inside a migration is not-done.
did this instead which works at this point: