From 84e46437fa50782dd38b96b8df00ca8b017c892e Mon Sep 17 00:00:00 2001 From: Anil Wadghule Date: Mon, 12 Apr 2010 22:20:55 +0530 Subject: Replace 'RAILS_ROOT' to 'Rails.root' and 'RAILS_ENV' to 'Rails.env' in significant places. --- railties/guides/source/3_0_release_notes.textile | 2 +- railties/guides/source/command_line.textile | 2 +- railties/guides/source/configuring.textile | 2 +- railties/guides/source/debugging_rails_applications.textile | 2 +- railties/guides/source/i18n.textile | 6 +++--- railties/guides/source/migrations.textile | 2 +- railties/guides/source/rails_application_templates.textile | 2 +- railties/guides/source/rails_on_rack.textile | 6 +++--- railties/lib/rails/application/configuration.rb | 2 +- railties/lib/rails/webrick_server.rb | 4 ++-- 10 files changed, 15 insertions(+), 15 deletions(-) (limited to 'railties') diff --git a/railties/guides/source/3_0_release_notes.textile b/railties/guides/source/3_0_release_notes.textile index 024cb48288..da69ada7b4 100644 --- a/railties/guides/source/3_0_release_notes.textile +++ b/railties/guides/source/3_0_release_notes.textile @@ -183,7 +183,7 @@ Railties generators got a huge amount of attention in Rails 3.0, basically: * Rails templates API and generators API were merged (they are the same as the former). * Generators are no longer loaded from special paths anymore, they are just found in the Ruby load path, so calling rails generate foo will look for generators/foo_generator. * New generators provide hooks, so any template engine, ORM, test framework can easily hook in. -* New generators allow you to override the templates by placing a copy at RAILS_ROOT/lib/templates. +* New generators allow you to override the templates by placing a copy at Rails.root/lib/templates. * Rails::Generators::TestCase is also supplied so you can create your own generators and test them. Also, the views generated by Railties generators had some overhaul: diff --git a/railties/guides/source/command_line.textile b/railties/guides/source/command_line.textile index f2b53023a5..ebae320ebc 100644 --- a/railties/guides/source/command_line.textile +++ b/railties/guides/source/command_line.textile @@ -530,7 +530,7 @@ You can get a list of Rake tasks available to you, which will often depend on yo rake db:abort_if_pending_migrations # Raises an error if there are pending migrations rake db:charset # Retrieves the charset for the current environment's database rake db:collation # Retrieves the collation for the current environment's database -rake db:create # Create the database defined in config/database.yml for the current RAILS_ENV +rake db:create # Create the database defined in config/database.yml for the current Rails.env ... ... rake tmp:pids:clear # Clears all files in tmp/pids diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile index 03d2519ee7..bd2289890a 100644 --- a/railties/guides/source/configuring.textile +++ b/railties/guides/source/configuring.textile @@ -163,7 +163,7 @@ WARNING: Threadsafe operation in incompatible with the normal workings of develo The caching code adds two additional settings: -* +ActionController::Base.page_cache_directory+ sets the directory where Rails will create cached pages for your web server. The default is +Rails.public_path+ (which is usually set to +RAILS_ROOT + "/public"+). +* +ActionController::Base.page_cache_directory+ sets the directory where Rails will create cached pages for your web server. The default is +Rails.public_path+ (which is usually set to +Rails.root + "/public"+). * +ActionController::Base.page_cache_extension+ sets the extension to be used when generating pages for the cache (this is ignored if the incoming request already has an extension). The default is +.html+. diff --git a/railties/guides/source/debugging_rails_applications.textile b/railties/guides/source/debugging_rails_applications.textile index 8f502bac99..0fb7542995 100644 --- a/railties/guides/source/debugging_rails_applications.textile +++ b/railties/guides/source/debugging_rails_applications.textile @@ -136,7 +136,7 @@ config.logger = Logger.new(STDOUT) config.logger = Log4r::Logger.new("Application Log") -TIP: By default, each log is created under +RAILS_ROOT/log/+ and the log file name is +environment_name.log+. +TIP: By default, each log is created under +Rails.root/log/+ and the log file name is +environment_name.log+. h4. Log Levels diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile index ec69f770ee..9e882bc0a1 100644 --- a/railties/guides/source/i18n.textile +++ b/railties/guides/source/i18n.textile @@ -103,7 +103,7 @@ The default +environment.rb+ files has instructions on how to add locales from a # The internationalization framework can be changed # to have another default locale (standard is :en) or more load paths. # All files from config/locales/*.rb,yml are added automatically. -# config.i18n.load_path << Dir[File.join(RAILS_ROOT, 'my', 'locales', '*.{rb,yml}')] +# config.i18n.load_path << Dir[File.join(Rails.root, 'my', 'locales', '*.{rb,yml}')] # config.i18n.default_locale = :de @@ -117,7 +117,7 @@ To tell the I18n library where it can find your custom translation files you can # in config/initializers/locale.rb # tell the I18n library where to find your translations -I18n.load_path << Dir[ File.join(RAILS_ROOT, 'lib', 'locale', +I18n.load_path << Dir[ File.join(Rails.root, 'lib', 'locale', '*.{rb,yml}') ] # set default locale to something other than :en @@ -423,7 +423,7 @@ NOTE: The default locale loading mechanism in Rails does not load locale files i # config/environment.rb - config.i18n.load_path += Dir[File.join(RAILS_ROOT, 'config', 'locales', '**', '*.{rb,yml}')] + config.i18n.load_path += Dir[File.join(Rails.root, 'config', 'locales', '**', '*.{rb,yml}')] Do check the "Rails i18n Wiki":http://rails-i18n.org/wiki for list of tools available for managing translations. diff --git a/railties/guides/source/migrations.textile b/railties/guides/source/migrations.textile index 558cbb4771..6f88ed6b3f 100644 --- a/railties/guides/source/migrations.textile +++ b/railties/guides/source/migrations.textile @@ -568,7 +568,7 @@ In many ways this is exactly what it is. This file is created by inspecting the There is however a trade-off: +db/schema.rb+ cannot express database specific items such as foreign key constraints, triggers or stored procedures. While in a migration you can execute custom SQL statements, the schema dumper cannot reconstitute those statements from the database. If you are using features like this then you should set the schema format to +:sql+. -Instead of using Active Record's schema dumper the database's structure will be dumped using a tool specific to that database (via the +db:structure:dump+ Rake task) into +db/#{RAILS_ENV}_structure.sql+. For example for PostgreSQL the +pg_dump+ utility is used and for MySQL this file will contain the output of +SHOW CREATE TABLE+ for the various tables. Loading this schema is simply a question of executing the SQL statements contained inside. +Instead of using Active Record's schema dumper the database's structure will be dumped using a tool specific to that database (via the +db:structure:dump+ Rake task) into +db/#{Rails.env}_structure.sql+. For example for PostgreSQL the +pg_dump+ utility is used and for MySQL this file will contain the output of +SHOW CREATE TABLE+ for the various tables. Loading this schema is simply a question of executing the SQL statements contained inside. By definition this will be a perfect copy of the database's structure but this will usually prevent loading the schema into a database other than the one used to create it. diff --git a/railties/guides/source/rails_application_templates.textile b/railties/guides/source/rails_application_templates.textile index 579b1a5538..baaa3d6d66 100644 --- a/railties/guides/source/rails_application_templates.textile +++ b/railties/guides/source/rails_application_templates.textile @@ -113,7 +113,7 @@ CODE Similarly +lib()+ creates a file in the +lib/+ directory and +vendor()+ creates a file in the +vendor/+ directory. -There is even +file()+, which accepts a relative path from +RAILS_ROOT+ and creates all the directories/file needed : +There is even +file()+, which accepts a relative path from +Rails.root+ and creates all the directories/file needed : file 'app/components/foo.rb', <<-CODE diff --git a/railties/guides/source/rails_on_rack.textile b/railties/guides/source/rails_on_rack.textile index 320ce137bb..d0d86e99f2 100644 --- a/railties/guides/source/rails_on_rack.textile +++ b/railties/guides/source/rails_on_rack.textile @@ -49,7 +49,7 @@ Middlewares used in the code above are primarily useful only in the development |_.Middleware|_.Purpose| |+Rails::Rack::LogTailer+|Appends log file output to console| -|+ActionDispatch::Static+|Serves static files inside +RAILS_ROOT/public+ directory| +|+ActionDispatch::Static+|Serves static files inside +Rails.root/public+ directory| |+Rails::Rack::Debugger+|Starts Debugger| h4. +rackup+ @@ -57,7 +57,7 @@ h4. +rackup+ To use +rackup+ instead of Rails' +rails server+, you can put the following inside +config.ru+ of your Rails application's root directory: -# RAILS_ROOT/config.ru +# Rails.root/config.ru require "config/environment" use Rails::Rack::LogTailer @@ -214,7 +214,7 @@ config.middleware.clear
-Add a +config.ru+ file to +RAILS_ROOT+ +Add a +config.ru+ file to +Rails.root+ # config.ru diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index 7ce3494fa6..11bf6a6e72 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -53,7 +53,7 @@ module Rails paths.vendor.plugins "vendor/plugins" if File.exists?("#{root}/test/mocks/#{Rails.env}") - ActiveSupport::Deprecation.warn "\"RAILS_ROOT/test/mocks/#{Rails.env}\" won't be added " << + ActiveSupport::Deprecation.warn "\"Rails.root/test/mocks/#{Rails.env}\" won't be added " << "automatically to load paths anymore in future releases" paths.mocks_path "test/mocks", :load_path => true, :glob => Rails.env end diff --git a/railties/lib/rails/webrick_server.rb b/railties/lib/rails/webrick_server.rb index 2f60151b22..f3b74c28d3 100644 --- a/railties/lib/rails/webrick_server.rb +++ b/railties/lib/rails/webrick_server.rb @@ -63,8 +63,8 @@ class DispatchServlet < WEBrick::HTTPServlet::AbstractServlet def initialize(server, options) #:nodoc: @server_options = options @file_handler = WEBrick::HTTPServlet::FileHandler.new(server, options[:server_root]) - # Change to the RAILS_ROOT, since Webrick::Daemon.start does a Dir::cwd("/") - # OPTIONS['working_directory'] is an absolute path of the RAILS_ROOT, set in railties/lib/commands/servers/webrick.rb + # Change to the Rails.root, since Webrick::Daemon.start does a Dir::cwd("/") + # OPTIONS['working_directory'] is an absolute path of the Rails.root, set in railties/lib/commands/servers/webrick.rb Dir.chdir(OPTIONS['working_directory']) if defined?(OPTIONS) && File.directory?(OPTIONS['working_directory']) super end -- cgit v1.2.3