> > > http://dev.rubyonrails.org/ticket/7383
> > >
> > > I submitted the patch a while back and refed it to the original ticket
> > > #3375.  If I need to update this patch for any reason to get it
> > > included please let me know.
>
> What's the rationale for having two options?   Perhaps we could
> deprecate allow_nil and add an 'optional' argument?  Or make all the
> validations allow blank and require validates_presence_of to prevent
> nil and blank inputs?

Say you want to validate the length something, as well as its
presence, without throwing two error messages:

validates_presence_of :something
validates_length_of :something, :is => 5, :allow_nil => true

Which doesnt work because through a form, :something is "", not nil.

Which would lead you to:

validates_presence_of :something
validates_length_of :something, :is => 5,
                    :if => Proc.new { |r| !r.something.blank? }

Which is unecessarily ugly.  Since we already have :allow_nil using
the #nil? logic, I think we should have :allow_blank using the
#blank? logic:

validates_presence_of :something
validates_length_of :something, :is => 5, :allow_blank => true

Been a while since I've visited this issue.  I've just implemented
the above workaround until this patch is applied.  But I'm pretty
sure that explanation is how I remember the issue.

Joe

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to