I found a few similar questions while searching here, but when I tried to add unless to the solutions I found, things started to break...
Here's what I have that works:
Controller:
@metrics = Metric.where("current_ratio > ?", @screen.current_ratio_min) unless @screen.current_ratio_min.nil?
Once I add another .where line (of which I need to add many),
@metrics = Metric.where("current_ratio > ?", @screen.current_ratio_min) unless @screen.current_ratio_min.nil?
.where("current_ratio < ?", @screen.current_ratio_max) unless @screen.current_ratio_max.nil?
I get an error:
undefined method `where' for false:FalseClass
I'm assuming this is because the first unless is ending my query. How do I apply an unless just to each individual condition? If that is, in fact, the problem :\
Thanks in advance!