and or operator in validates_presence_of of a Ruby on Rails model

Posted by user284194 on Stack Overflow See other posts from Stack Overflow or by user284194
Published on 2010-03-15T23:06:35Z Indexed on 2010/03/15 23:09 UTC
Read the original article Hit count: 283

Filed under:
|
|
|

I have an entry.rb model and I'm trying to make a semi-complicated validation. I want it to require one or more of the following fields: phone, phone2, mobile, fax, email or website. How would you write the intended code? Would something like this work?

validates_presence_of :phone and or :phone2 and or :mobile and or :fax and or :email and or :website

© Stack Overflow or respective owner

Related posts about ruby

Related posts about ruby-on-rails