geared_pagination
geared_pagination copied to clipboard
Extending unscope?
Hi there
I'm currently building an API with geared_pagination and was wondering if it would make sense to add unscope(:select, :order, :group) to GearedPagination::Recordset#records_count as it otherwise causes some trouble with more complex queries. I don't think select, order and group are required here. But maybe I'm missing something?
For example here is a query that I'm trying to resolve:
Event.joins(:event_parts)
.where('event_parts.ends_at > ?', Time.zone.now)
.order(Arel.sql('min(event_parts.starts_at)'))
.group('events.id')
.preload(:event_parts)
Which results in an TypeError: no implicit conversion of Integer into Hash exception because the count result is grouped by events.id.
I realized this issue was here after I ran into it myself. This PR https://github.com/basecamp/geared_pagination/pull/49 fixes it