-
-
Notifications
You must be signed in to change notification settings - Fork 781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Weird behaviour using 'each' on Ransack results #340
Comments
Check the SQL being used. The |
Right. I understand that @graywh. Indeed, the SQL is counting DISTINCT users. But the thing is, shouldn't Ransack be retrieving unique results already? Given that is a search what you are performing. |
Hi @ronald05arias, would your issue be solved by point 3 under Simple Mode in the README instructions? |
It does @jonatack ! Thanks for pointing it out. |
You're welcome :) I reckon @ernie opted for |
I am experiencing a wrong behaviour on Ransack results, when using different fields to search for.
An example above:
q[email_or_social_email_cont]
res = Model.search(params[:q]).results
I am getting the proper results (1 in this case), also res.count is the proper count (1 in this case), but when running the
'each'
method on the collection, I got duplicates.Example:
{:email => 'user@email.com', :social_email => 'user@email.com'}
u = User.search(email_or_social_email_cont: 'user@email.com').results
u.count
equals to 1u.each { |u1| puts u1.email }
prints the email 2 times.I have to run
res.uniq.each
to make it work properly.Is there something "hacky" being done in the search method?
Thanks.
The text was updated successfully, but these errors were encountered: