2

I'd like to create the following and set is_seen to false explicitly.

rails g model notification body: text, user_id: integer, is_seen: boolean 

I know how to update this alter via a change_column but how would I set this to false at this point?

This is not for a migration but from creating a model.

halfer
  • 19,824
  • 17
  • 99
  • 186
timpone
  • 19,235
  • 36
  • 121
  • 211
  • Possible duplicate of [Can I pass default value to rails generate migration?](http://stackoverflow.com/questions/24565589/can-i-pass-default-value-to-rails-generate-migration) – MarsAtomic Oct 05 '15 at 00:54

1 Answers1

3

You can't set the default value while creating the model/migration at that point.

You have to create/edit the migration file and change the corresponding line to something like this:

add_column :table, :is_seen, :boolean, default: false
K M Rakibul Islam
  • 33,760
  • 12
  • 89
  • 110