I have a table QualifyingEvents. I am attempting to search the table for records created on a particular date with their course_id and / or their sponsor_name. I'm following the examples in RailsGuides Active Record Query Interface: http://guides.rubyonrails.org/active_record_querying.html
I couldn't get a query of this form to work:
QualifyingEvent.find([:date = 'x', :course_id = 'x', :sponsor_name ='x'])
Nor this form:
QualifyingEvent.where(":course_id = ?", x )
However, this works - with the commas being interpreted as "and":
QualifyingEvent.find_by date: '2014', course_id: '96789', sponsor_name: 'Maggio and Sons'
Now, how do I get a record if I want a match on two of the three fields? I've tried using && and || with no luck. What is the correct syntax? Also, why does "find_by" work when "find" doesn't?
Thank you, in advance, for your help.