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.

1

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.