On Nov 14, 2013, at 8:14 AM, Sergio Campamá wrote:

> Last night a friend of mine started ranting about validates_presence_of 
> :boolean_field returning not valid when the boolean field is false. 
> 
> I checked the rails issues and this seems to be a pretty common concern about 
> the naming of  'presence' .
> 
> Instead of changing the behaviour of the presence validator, I was wondering 
> if maybe the answer to avoid such misconceptions could be to create a new 
> validator called presence_of_boolean that abstracts the sometimes called 
> "hacky" validates_inclusion in: [true, false]
> 
> What do you guys think?

I think that if you're putting boolean columns in your DB that don't default to 
either true or false you are doing it wrong. If you really want "yes / no / 
didn't answer" semantics, use a type that represents that.

--Matt Jones

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to