Adjusted how Rails environment is detected.