[Rails] Re: stuck on a validates_presence_of unless issue

2008-11-02 Thread hoenth

I must have looked at those API docs 10 times and didn't see it. Would
have bitten...and all that.

Thanks for the quick response Craig. Worked like a charm.
Tom

On Nov 1, 9:05 am, "Craig Demyanovich" <[EMAIL PROTECTED]> wrote:
> On Sat, Nov 1, 2008 at 5:29 AM, hoenth <[EMAIL PROTECTED]> wrote:
>
> > i have a person object. Persons don't need to have addresses, but if
> > they have any address field value, they must have them all. So I have
> > something like this:
>
> > validates_presence_of :street_address, :city, :state, :postal_code
> > unless :address_blank?
>
> Instead of
>
> unless :address_blank?
>
> use
>
> :unless => :address_blank?
>
> since you need to pass options to validates_presence_of as opposed to
> writing a normal conditional. See the API docs for validates_presence_of for
> more details if you need them.
>
> Regards,
> Craig
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: stuck on a validates_presence_of unless issue

2008-11-01 Thread Craig Demyanovich
On Sat, Nov 1, 2008 at 5:29 AM, hoenth <[EMAIL PROTECTED]> wrote:

>
> i have a person object. Persons don't need to have addresses, but if
> they have any address field value, they must have them all. So I have
> something like this:
>
> validates_presence_of :street_address, :city, :state, :postal_code
> unless :address_blank?


Instead of

unless :address_blank?

use

:unless => :address_blank?

since you need to pass options to validates_presence_of as opposed to
writing a normal conditional. See the API docs for validates_presence_of for
more details if you need them.

Regards,
Craig

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