The simplest way to select all distinct values of a column is, somewhat unintuitively:


this runs the query select distinct project from visits, and returns an array of strings. Exactly what you need, except … I want it to be paginated. So we


… and that completely bombs: we now get an array of numbers?

So we try something else, and write:'distinct project') 

which runs the good query, but returns an array of Visit‘s with only the project filled in. I can live with that. And then pagination (using the kaminari gem) is again as expected:'distinct project').page(params[:page])

Nice :)