[Rails] Provide a wrapper method for Rails.root/RAILS_ROOT that avoids deprecation warnings and handles the case where rails is not loaded at all.

This commit is contained in:
Chris Eppstein 2010-05-30 10:37:00 -07:00
parent 981bbd2b18
commit 6ab85ecd83
2 changed files with 9 additions and 1 deletions

View File

@ -26,6 +26,14 @@ module Compass
end end
end end
def root
if defined?(::Rails)
::Rails.root
elsif defined?(RAILS_ROOT)
RAILS_ROOT
end
end
end end
end end
end end

View File

@ -94,7 +94,7 @@ NEXTSTEPS
"# This configuration file works with both the Compass command line tool and within Rails.\n" + "# This configuration file works with both the Compass command line tool and within Rails.\n" +
Compass.configuration.serialize do |prop, value| Compass.configuration.serialize do |prop, value|
if prop == :project_path if prop == :project_path
"project_path = RAILS_ROOT if defined?(RAILS_ROOT)\n" "project_path = Compass::AppIntegration::Rails.root\n"
elsif prop == :environment elsif prop == :environment
"environment = Compass::AppIntegration::Rails.env\n" "environment = Compass::AppIntegration::Rails.env\n"
elsif prop == :output_style elsif prop == :output_style