Yes, I get what you mean Rafael.

I think the main misconception is that in the database sense, a value of
'false' is indeed present, and the only way for that field to be NOT
present would be for it to be NULL, again in the database.

Now, in the application context, it is commonly believed that a value of
false translates to not being present. So there is the confusion.

Reading up the source, I now understand better that validations work on the
application context (besides ActiveRecord validators), so it makes sense to
use the inclusion validator.

Thanks,


On Thu, Nov 14, 2013 at 10:34 AM, Rafael Mendonça França <
rafaelmfra...@gmail.com> wrote:

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

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