(First message!) a strange way to read a constant

Heh, I wanted to post the first message on Google groups :slight_smile:

I always wondered why such a strange way to read RAILS_GEM_VERSION in config/boot.rb:

   environment_without_comments = IO.readlines(File.dirname(__FILE__) +    '/environment.rb').reject { |l| l =~ /^#/ }.join    environment_without_comments =~ /[^#]RAILS_GEM_VERSION = '([\d.]+)'/    rails_gem_version = $1

Basically it reads environment.rb as a file and searches for the constant if it's not commented out.

Why such a hackish way? The constant is already defined when boot.rb executes...

-Mislav

I think environment.rb does not get parsed until later, when you call Rails::Initializer.run(:set_load_path).

In the dispatch process, environment.rb calls boot.rb, not the other way around. Initializer#set_load_path just sets load paths for the app and has nothing to do with this…

That's right, my mistake. In that case I am also curious as to why this hackish approach.