-
Type: Improvement
-
Resolution: Fixed
-
Priority: Minor - P4
-
Affects Version/s: 7.0.5
-
Component/s: Dev Exp
-
Fully Compatible
When Mongoid cannot determine the environment to use, it raises the following exception:
/home/me/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/mongoid-7.0.5/lib/mongoid/config/environment.rb:24:in `env_name': (Mongoid::Errors::NoEnvironment)
message:
Could not load the configuration since no environment was defined.
summary:
Mongoid attempted to find the appropriate environment but no Rails.env, Sinatra::Base.environment, RACK_ENV, or MONGOID_ENV could be found.
resolution:
Make sure some environment is set from the mentioned options. Mongoid cannot load configuration from the yaml without knowing which environment it is in, and we have considered defaulting to development an undesireable side effect of this not being defined.
In this message, Rails.env and Sinatra::Base are valid Ruby code, but RACK_ENV and MONGOID_ENV are not - the latter are not recognized as constants but only as keys in ENV.
The exception message should explicitly state that the latter two references are to ENV keys.