
03-18-2009, 06:45 AM
|
|
Member
|
|
Join Date: Oct 2008
Posts: 20
|
|
Quote:
Originally Posted by mistwang
actually, config/boot.rb does exactly what I want. just need to duplicate that code. 
|
Based on running in the rails root:
Code:
environmentrb = File.read('config/environment.rb')
puts $1 if environmentrb =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
If you have loaded rails then you can use:
Code:
File.read("#{RAILS_ROOT}/config/environment.rb")
and it'll pull in the full file path too.
Ta
Luke
|