I'm trying to build the where clause using AREL but this does not execute the query:
rec = self.where('color' => color_passed)
rec = rec.where('make' => make_passed) if make_passed.present?
rec = rec.where('year' => year_passed) if year_passed.present?
How can I correctly append the where conditions based on some conditions?
What do you mean not execute? where
only return a Relation object, you have to call all
to get the result:
rec.all