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)
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)
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs