Rails 4 allocate different columns in postgres, where is the limit

How do you select multiple fields with different values ​​and other implicit fields with them, all in one call using and limit? I tried .pluck (which supports multiple fields in rails 4),. Uniq (which in my case does not work).

+4
source share
1 answer

This is what worked for me when it is used in a controller action

@models = Model.select('DISTINCT ON (field1,field2,field3) *')
     .where(id: params[:id])
     .limit(100)
+4
source

All Articles