fixed issue where redirect_to will not work inside models so moved file permission error handling to the controller instead