i was trying to sort values of a table with sort_link from Ransack. i found an example which is really helpful. but, i think i'm having problem with 'distinct'. i got this error 'ORDER-BY expressions must appear in SELECT list; DISTINCT'. my code looks like this :
q =user.joins(:buyer).order('users.name')
ransack = params["filter"]
@search = q.search(ransack)
@users = @search.result(:distinct=>true)
do i forget something? thanks in advance!
As per this issue you might be able to solve this with an ActiveRecord joins query or select query to add the columns needed, for example:
q = user.order('users.name')
ransack = params["filter"]
@search = q.search(ransack).
result(:distinct=>true).
joins(:buyer).
includes(:buyer)
@users = @search.all
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With