My users are (booleans) students, tutors, or 'both'. My users are automatically false on all 3 unless specified, but I want the default value of 'both' to be based on a user being both a student and a tutor, therefore if student and tutor are booleans, both = student && tutor. How can I create a migration to do this?
Migration file that did not work.
class ChangeUserBoth < ActiveRecord::Migration
def change
change_column :users, :both, :boolean, :default => :student && :tutor
end
end
You can't pass a conditional method in while writing your migration code, but you can achieve the desired result through the following way: