Model.exists?(:attr1 => "x", :attr2 => "y", :attr3
=> "z")
note that the the conditions will be ANDed. if you need to use OR,
then you need to use a different conditions format
Model.exists?(["attr1 = ? OR att1 = ?", x, y])
Chris
On 6/26/07, Neil Hoyne
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
> Is there any way to use .exists? to check multiple conditions? Ideally,
> I''d like to verify it against four other fields. Thanks in
advance!
>
>
> if Contact.exists?(:mobilephone => @contact.mobilephone)
>
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---