mysql - How to build a SQL 'OR' query by using Rails facilities? -
i using ruby on rails 3.2.2 and, given have stated needed classes/models involved in question, build following sql query statement (note sql or) "a là ruby on rails way":
select customers.* customers (firstname = 'james' or firstname = 'paula') , lastname = 'brown' is possible using rails facilities?
you not looking or. rather, looking in.
select customers.* customers firstname in ('james','paula') , lastname = 'brown' this has been supported in rails long time(may since inception). can specify array of values instead of single value in finds.
@firstnames = ['james','paula'] @lastname = 'brown' @customers = customer.find_all_by_firstname_and_lastname(@firstnames,@lastname)
Comments
Post a Comment