I’m wondering if there’s any convention preference against setting default boolean values as true or false. Maybe its beyond the scope of ActiveRecord and is more a general db design question.
I have a model with an active? attribute where by default all records are active.
Is it better to have a migration with :active, :boolean, default: true or :inactive, :boolean, default: false ?
In my experience (Rails or otherwise), boolean attributes are most easily understood when they are phrased in the positive.
If you think about your example, you are really choosing between “active” and “not active”. Choosing “inactive” (which again, is really just “not active”) makes the code harder to read since I have to mentally negate the word “active” to understand what the code is doing.
It may seem like a small thing but I really think that “active” is the better choice.
To see what I mean, use your two different migrations as examples to see the difference in readability:
Which of those two comments are easier to read and understand? I find the first one to be clearer.