Skip to content
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

Datatables paging when ActiveRecord query uses .group #356

Open
toomanyjoes opened this issue Mar 7, 2020 · 0 comments
Open

Datatables paging when ActiveRecord query uses .group #356

toomanyjoes opened this issue Mar 7, 2020 · 0 comments

Comments

@toomanyjoes
Copy link

toomanyjoes commented Mar 7, 2020

If the activerecord query that feeds the datatable uses group it totally breaks paging. I assume this is because .count is being called on the result set at some point when creating page elements and for a group by query .count returns a hash not a number.

My work around was to make another query in get_raw_records that uses a subquery on the model I'm querying to pluck the elements by their ids from the first query. Since this query is just a .where .count returns a number and it works. But it seems like this could be an easy fix if when using .count the code first checked for a hash before assuming it was returning a number.

@toomanyjoes toomanyjoes changed the title Datatables paging when ActiveRecord query uses group Datatables paging when ActiveRecord query uses .group Mar 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant