When rails application is created, there is a line in config.ru file:
require ::File.expand_path('../config/environment', __FILE__)
Could you explain, why we need ::File and not just File? Will require File.expand_path work?
When rails application is created, there is a line in config.ru file:
require ::File.expand_path('../config/environment', __FILE__)
Could you explain, why we need ::File and not just File? Will require File.expand_path work?
:: at the beginning represents the main name space. Suppose the current environment is within module A. If you have just File, then it will first look for A::File, and only when such constant does not exist does it look for File in the main name space. On the other hand, ::File refers to File in the main name space regardless of whether there is such thing as A::File.