I’m relatively new to Rails and was wondering what the reasoning behind the following is:
I have a boolean field processed that I want to set to false by default:
before_validation(on: :create) do
self.processed ||= false
end
validates :processed, presence: true
This only works if I modify it to the following, which with my knowledge don’t find intuitive:
before_validation(on: :create) do
self.processed ||= false
true
end
validates :processed, inclusion: { in: [true, false] }
Is this a design choice or is it simply too hard too implement (Object#blank etc)?