Added additional protection for the ID of Rails environment, used in less than ideal sinatra environments for instance