This will cause more misconceptions yet.

validate_presence_of :something

Means to me

something.prensent?

And

false.present? # => false

So even we call presence_of_boolean we still using the word presence that
means that I should expect to Rails call present?

validates_inclusion is not “hacky” to me, it is exactly what you want,
check if your value is included in the [true, false] array.

Rafael Mendonça França
http://twitter.com/rafaelfranca
https://github.com/rafaelfranca


On Thu, Nov 14, 2013 at 11:14 AM, Sergio Campamá <ser...@satelinx.com>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?
>
> Sergio Campamá
>
>
>  --
> 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.
>

-- 
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