allegroplanet / allegro-planet

1 stars 1 forks source link

Fix presence validation on boolean "published" for Article #66

Closed MarkOates closed 5 years ago

MarkOates commented 5 years ago

Problem

Currently, it's not possible to set an article's published to false! Because of the way Rails handles presence validations, a false value indicates to Rails that the value is not present.

Solution

To fix this, I'll replace the presence: true validation with a inclusion: { in: [true, false]}, along with an error message. This will still prevent nil values from being permitted, as is indicated by an updated test.

This solution was provided by https://github.com/trailblazer/reform-rails/issues/47#issuecomment-293002004. Thank you.


This is a fix to https://github.com/allegroplanet/allegro-planet/pull/65