module UserHelper
  def guider_options
    groups = Group.includes(:users)
    {
      'Groups': groups.map do |group|
        [group.name, group.name, data: { icon: 'glyphicon-tag', children_to_select: group.users.pluck(:id) }]
      end,
      'Users': User.guiders.active.map do |guider|
        [guider.name, guider.id, data: { icon: 'glyphicon-user' }]
      end
    }
  end
end

module UserHelper
  def guider_options
    groups = Group.includes(:users)

    {
      'Groups': groups.map do |group|
        [group.name, group.name, data: { icon: 'glyphicon-tag', children_to_select: group.user_ids }]
      end,
      'Users': User.guiders.active.map do |guider|
        [guider.name, guider.id, data: { icon: 'glyphicon-user' }]
      end
    }
  end
end

Reduce huge N+1 querying for associated user IDs
Reduce huge N+1 querying for associated user IDs

This was causing a huge N+1 query through groups / assignments / users.
