Closed GarPit closed 10 years ago
Show me your code please
def initialize(repository = BackOfficeUser.scoped)
@repository = repository.joins(:roles).joins(
"INNER JOIN (VALUES #{roles}) as translated_roles(name, translated) ON back_office_roles.name = translated_roles.name"
).select("back_office_users.*, string_agg(translated_roles.translated, ', ') as translated_roles_names").group("back_office_users.id")
end
How is this code related to WiceGrid? Where is an initialize_grid
call?
Here it is:
@back_office_users_grid = initialize_grid(
BackOfficeUser::FilterForSysAdminQuery.new.build(params[:search]),
order: 'back_office_users.created_at',
order_direction: 'desc',
custom_order: {
'back_office_roles.name' => 'translated_roles_names'
}
)
FilterForSysAdminQuery will call initialize and return ActiveRelation
I will take a closer look but I seriously doubt that WiceGrid can work correctly with group
.
Yes, seems you're right. But it's not so difficult to add support for this. I use this workaround:
collection_total_entries_count = collection_total_entries.is_a?(Hash) ? collection_total_entries.count : collection_total_entries
As I do not have much time for this plugin I would welcome any pull request. Бельгийское пиво за мной :)
Ok :+1:
generally the problem is that collection.size returns a hash for grouped queries. collection.length returns the number of grouped records.
Yes, exactly
This happens in method 'pagination_info' when I have 'group' in query.
In this case collection_total_entries is a Hash similar to this one: