From 6ab85ecd83b922ea5b5434d94345133f25337254 Mon Sep 17 00:00:00 2001 From: Chris Eppstein Date: Sun, 30 May 2010 10:37:00 -0700 Subject: [PATCH] [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. --- lib/compass/app_integration/rails.rb | 8 ++++++++ lib/compass/app_integration/rails/installer.rb | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/compass/app_integration/rails.rb b/lib/compass/app_integration/rails.rb index 0e5c6a84..d1f370ae 100644 --- a/lib/compass/app_integration/rails.rb +++ b/lib/compass/app_integration/rails.rb @@ -26,6 +26,14 @@ module Compass end end + def root + if defined?(::Rails) + ::Rails.root + elsif defined?(RAILS_ROOT) + RAILS_ROOT + end + end + end end end diff --git a/lib/compass/app_integration/rails/installer.rb b/lib/compass/app_integration/rails/installer.rb index bb66436d..9652c0e3 100644 --- a/lib/compass/app_integration/rails/installer.rb +++ b/lib/compass/app_integration/rails/installer.rb @@ -94,7 +94,7 @@ NEXTSTEPS "# This configuration file works with both the Compass command line tool and within Rails.\n" + Compass.configuration.serialize do |prop, value| if prop == :project_path - "project_path = RAILS_ROOT if defined?(RAILS_ROOT)\n" + "project_path = Compass::AppIntegration::Rails.root\n" elsif prop == :environment "environment = Compass::AppIntegration::Rails.env\n" elsif prop == :output_style