Fixes #4976 - ensure the process is really running inside a rake task
fixes #4995 - editing location with 'all users' checked fails on edit page in postgres