In a Rails model I have an attribute is_subscriber
, when I constructed a db migration to add this column to the database I specified the default value to be false:
t.boolean "is_subscriber", :default => false
I also specified in the model that this attribute needs to be present:
validates :is_subscriber, presence: true
So why do I get this error when I create a model instance without specifying this attribute?
2012-05-08T21:05:54+00:00 app[web.1]: ActiveRecord::RecordInvalid (Validation failed: Is subscriber can't be blank):
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…