I've stumbled across this answer and it has helped me to generate a list of unique values exactly as I wanted, however, I don't want all of the results. Is there any way to filter the results within the select
or another way to accomplish this?
I was thinking of something along the lines of this:
@results = MyModel.select("DISTINCT(columnForDistinction)", :myBoolean => false)
or
@results = MyModel.select("DISTINCT(columnForDistinction)", :someString => stringImLookingFor)
Currently, I'm not able to filter the results on the query, so I am iterating over the returned array and only listing the results that have that boolean set to false like so:
<% @results.each do |result| %>
<% if !result.myBoolean %>
#do stuff here
<% end %>
<% end %>
and
<% @results.each do |result| %>
<% if result.someString == stringImLookingFor %>
#do stuff here
<% end %>
<% end %>
Is there a better way to be doing this?