Fix for when RAILS_ENV is not available

Switch from ENV['RAILS_ENV'] to Rails.env