Refer to Rails.env only when Rails is defined
Merge pull request #12845 from amatsuda/should_ar_depend_on_rails

Refer to Rails.env from AR only when Rails is defined