Fixes race condition in resources

See #1378.
Replace this for-loop with ``resources.update(group_id=group.id)`` for greater efficiency.