aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/tasks
diff options
context:
space:
mode:
authorCarl Lerche <carllerche@mac.com>2009-10-16 12:49:39 -0700
committerCarl Lerche <carllerche@mac.com>2009-10-16 12:51:02 -0700
commit2110a524a4913815d036786aa01319fd67db0ee2 (patch)
treef87858a81ac61642827c0617cad9eeceb44e8707 /railties/lib/rails/tasks
parent6094e6516951444f8c3d6bb31f171af9fe96a02f (diff)
downloadrails-2110a524a4913815d036786aa01319fd67db0ee2.tar.gz
rails-2110a524a4913815d036786aa01319fd67db0ee2.tar.bz2
rails-2110a524a4913815d036786aa01319fd67db0ee2.zip
Deprecate RAILS_ROOT in favor of Rails.root (which proxies to the application's object root)
Diffstat (limited to 'railties/lib/rails/tasks')
-rw-r--r--railties/lib/rails/tasks/databases.rake24
-rw-r--r--railties/lib/rails/tasks/framework.rake8
-rw-r--r--railties/lib/rails/tasks/gems.rake2
-rw-r--r--railties/lib/rails/tasks/misc.rake2
4 files changed, 18 insertions, 18 deletions
diff --git a/railties/lib/rails/tasks/databases.rake b/railties/lib/rails/tasks/databases.rake
index ed015e7a67..70b59625f8 100644
--- a/railties/lib/rails/tasks/databases.rake
+++ b/railties/lib/rails/tasks/databases.rake
@@ -283,7 +283,7 @@ namespace :db do
desc "Create a db/schema.rb file that can be portably used against any DB supported by AR"
task :dump => :environment do
require 'active_record/schema_dumper'
- File.open(ENV['SCHEMA'] || "#{RAILS_ROOT}/db/schema.rb", "w") do |file|
+ File.open(ENV['SCHEMA'] || "#{Rails.root}/db/schema.rb", "w") do |file|
ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection, file)
end
Rake::Task["db:schema:dump"].reenable
@@ -291,11 +291,11 @@ namespace :db do
desc "Load a schema.rb file into the database"
task :load => :environment do
- file = ENV['SCHEMA'] || "#{RAILS_ROOT}/db/schema.rb"
+ file = ENV['SCHEMA'] || "#{Rails.root}/db/schema.rb"
if File.exists?(file)
load(file)
else
- abort %{#{file} doesn't exist yet. Run "rake db:migrate" to create it then try again. If you do not intend to use a database, you should instead alter #{RAILS_ROOT}/config/environment.rb to prevent active_record from loading: config.frameworks -= [ :active_record ]}
+ abort %{#{file} doesn't exist yet. Run "rake db:migrate" to create it then try again. If you do not intend to use a database, you should instead alter #{Rails.root}/config/environment.rb to prevent active_record from loading: config.frameworks -= [ :active_record ]}
end
end
end
@@ -307,7 +307,7 @@ namespace :db do
case abcs[RAILS_ENV]["adapter"]
when "mysql", "oci", "oracle"
ActiveRecord::Base.establish_connection(abcs[RAILS_ENV])
- File.open("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump }
+ File.open("#{Rails.root}/db/#{RAILS_ENV}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump }
when "postgresql"
ENV['PGHOST'] = abcs[RAILS_ENV]["host"] if abcs[RAILS_ENV]["host"]
ENV['PGPORT'] = abcs[RAILS_ENV]["port"].to_s if abcs[RAILS_ENV]["port"]
@@ -327,13 +327,13 @@ namespace :db do
when "firebird"
set_firebird_env(abcs[RAILS_ENV])
db_string = firebird_db_string(abcs[RAILS_ENV])
- sh "isql -a #{db_string} > #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql"
+ sh "isql -a #{db_string} > #{Rails.root}/db/#{RAILS_ENV}_structure.sql"
else
raise "Task not supported by '#{abcs["test"]["adapter"]}'"
end
if ActiveRecord::Base.connection.supports_migrations?
- File.open("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql", "a") { |f| f << ActiveRecord::Base.connection.dump_schema_information }
+ File.open("#{Rails.root}/db/#{RAILS_ENV}_structure.sql", "a") { |f| f << ActiveRecord::Base.connection.dump_schema_information }
end
end
end
@@ -356,28 +356,28 @@ namespace :db do
when "mysql"
ActiveRecord::Base.establish_connection(:test)
ActiveRecord::Base.connection.execute('SET foreign_key_checks = 0')
- IO.readlines("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql").join.split("\n\n").each do |table|
+ IO.readlines("#{Rails.root}/db/#{RAILS_ENV}_structure.sql").join.split("\n\n").each do |table|
ActiveRecord::Base.connection.execute(table)
end
when "postgresql"
ENV['PGHOST'] = abcs["test"]["host"] if abcs["test"]["host"]
ENV['PGPORT'] = abcs["test"]["port"].to_s if abcs["test"]["port"]
ENV['PGPASSWORD'] = abcs["test"]["password"].to_s if abcs["test"]["password"]
- `psql -U "#{abcs["test"]["username"]}" -f #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql #{abcs["test"]["database"]}`
+ `psql -U "#{abcs["test"]["username"]}" -f #{Rails.root}/db/#{RAILS_ENV}_structure.sql #{abcs["test"]["database"]}`
when "sqlite", "sqlite3"
dbfile = abcs["test"]["database"] || abcs["test"]["dbfile"]
- `#{abcs["test"]["adapter"]} #{dbfile} < #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql`
+ `#{abcs["test"]["adapter"]} #{dbfile} < #{Rails.root}/db/#{RAILS_ENV}_structure.sql`
when "sqlserver"
`osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql`
when "oci", "oracle"
ActiveRecord::Base.establish_connection(:test)
- IO.readlines("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql").join.split(";\n\n").each do |ddl|
+ IO.readlines("#{Rails.root}/db/#{RAILS_ENV}_structure.sql").join.split(";\n\n").each do |ddl|
ActiveRecord::Base.connection.execute(ddl)
end
when "firebird"
set_firebird_env(abcs["test"])
db_string = firebird_db_string(abcs["test"])
- sh "isql -i #{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql #{db_string}"
+ sh "isql -i #{Rails.root}/db/#{RAILS_ENV}_structure.sql #{db_string}"
else
raise "Task not supported by '#{abcs["test"]["adapter"]}'"
end
@@ -446,7 +446,7 @@ def drop_database(config)
when /^sqlite/
require 'pathname'
path = Pathname.new(config['database'])
- file = path.absolute? ? path.to_s : File.join(RAILS_ROOT, path)
+ file = path.absolute? ? path.to_s : File.join(Rails.root, path)
FileUtils.rm(file)
when 'postgresql'
diff --git a/railties/lib/rails/tasks/framework.rake b/railties/lib/rails/tasks/framework.rake
index 16dd0af44e..3d7e4b5453 100644
--- a/railties/lib/rails/tasks/framework.rake
+++ b/railties/lib/rails/tasks/framework.rake
@@ -86,7 +86,7 @@ namespace :rails do
template = File.expand_path(template) if template !~ %r{\A[A-Za-z][A-Za-z0-9+\-\.]*://}
require 'generators'
- generator = Rails::Generators::App.new [ RAILS_ROOT ], {}, :destination_root => RAILS_ROOT
+ generator = Rails::Generators::App.new [ Rails.root ], {}, :destination_root => Rails.root
generator.apply template, :verbose => false
end
@@ -96,7 +96,7 @@ namespace :rails do
require 'rails/generators/rails/app/app_generator'
generator = Rails::Generators::AppGenerator.new ["rails"], { :with_dispatchers => true },
- :destination_root => RAILS_ROOT
+ :destination_root => Rails.root
generator.invoke(method)
end
@@ -117,8 +117,8 @@ namespace :rails do
desc "Rename application.rb to application_controller.rb"
task :application_controller do
- old_style = RAILS_ROOT + '/app/controllers/application.rb'
- new_style = RAILS_ROOT + '/app/controllers/application_controller.rb'
+ old_style = Rails.root + '/app/controllers/application.rb'
+ new_style = Rails.root + '/app/controllers/application_controller.rb'
if File.exists?(old_style) && !File.exists?(new_style)
FileUtils.mv(old_style, new_style)
puts "#{old_style} has been renamed to #{new_style}, update your SCM as necessary"
diff --git a/railties/lib/rails/tasks/gems.rake b/railties/lib/rails/tasks/gems.rake
index f1c34c7cca..1903efd5f6 100644
--- a/railties/lib/rails/tasks/gems.rake
+++ b/railties/lib/rails/tasks/gems.rake
@@ -61,7 +61,7 @@ def current_gems
end
def frozen_gems(load_specs=true)
- Dir[File.join(RAILS_ROOT, 'vendor', 'gems', '*-*')].map do |gem_dir|
+ Dir[File.join(Rails.root, 'vendor', 'gems', '*-*')].map do |gem_dir|
Rails::GemDependency.from_directory_name(gem_dir, load_specs)
end
end
diff --git a/railties/lib/rails/tasks/misc.rake b/railties/lib/rails/tasks/misc.rake
index fb2fc31dc1..7f244ebaed 100644
--- a/railties/lib/rails/tasks/misc.rake
+++ b/railties/lib/rails/tasks/misc.rake
@@ -1,7 +1,7 @@
task :default => :test
task :environment do
$rails_rake_task = true
- require(File.join(RAILS_ROOT, 'config', 'environment'))
+ require(File.join(Rails.root, 'config', 'environment'))
end
task :rails_env do