diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2013-04-24 20:57:09 +0200 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2013-04-24 20:59:39 +0200 |
commit | 20f1495af8a3461dab4c8378a2c774d694b17c51 (patch) | |
tree | ae23519ce501db004cce48c453ab2a00c5a565f5 | |
parent | 414ab0c4f42d7cb4bf9af075d38527cf5728d9bd (diff) | |
download | rails-20f1495af8a3461dab4c8378a2c774d694b17c51.tar.gz rails-20f1495af8a3461dab4c8378a2c774d694b17c51.tar.bz2 rails-20f1495af8a3461dab4c8378a2c774d694b17c51.zip |
Don't require Rails.env in order to use AR::Tasks::DatabaseTasks
-rw-r--r-- | activerecord/lib/active_record/railtie.rb | 1 | ||||
-rw-r--r-- | activerecord/lib/active_record/tasks/database_tasks.rb | 13 |
2 files changed, 8 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/railtie.rb b/activerecord/lib/active_record/railtie.rb index ed3df1661a..e36888d4a8 100644 --- a/activerecord/lib/active_record/railtie.rb +++ b/activerecord/lib/active_record/railtie.rb @@ -37,6 +37,7 @@ module ActiveRecord rake_tasks do require "active_record/base" + ActiveRecord::Tasks::DatabaseTasks.env = Rails.env ActiveRecord::Tasks::DatabaseTasks.db_dir = Rails.application.config.paths["db"].first ActiveRecord::Tasks::DatabaseTasks.seed_loader = Rails.application ActiveRecord::Tasks::DatabaseTasks.database_configuration = Rails.application.config.database_configuration diff --git a/activerecord/lib/active_record/tasks/database_tasks.rb b/activerecord/lib/active_record/tasks/database_tasks.rb index 1a173a11b7..5d3f34a9b0 100644 --- a/activerecord/lib/active_record/tasks/database_tasks.rb +++ b/activerecord/lib/active_record/tasks/database_tasks.rb @@ -17,6 +17,7 @@ module ActiveRecord # # The possible config values are the following: # + # * env: current environment # * db_dir: your 'db' directory # * seed_loader: an object which will load seeds, it needs to respond to `load_seed` method # * database_configuration: configuration of your databases (as in config/database.yml) @@ -36,7 +37,7 @@ module ActiveRecord attr_writer :current_config attr_accessor :database_configuration, :migrations_paths, :seed_loader, :db_dir, - :fixtures_path + :fixtures_path, :env LOCAL_HOSTS = ['127.0.0.1', 'localhost'] @@ -54,7 +55,7 @@ module ActiveRecord register_task(/(oci|oracle)/, ActiveRecord::Tasks::OracleDatabaseTasks) def current_config(options = {}) - options.reverse_merge! :env => Rails.env + options.reverse_merge! :env => env if options.has_key?(:config) @current_config = options[:config] else @@ -80,7 +81,7 @@ module ActiveRecord each_local_configuration { |configuration| create configuration } end - def create_current(environment = Rails.env) + def create_current(environment = env) each_current_configuration(environment) { |configuration| create configuration } @@ -103,7 +104,7 @@ module ActiveRecord each_local_configuration { |configuration| drop configuration } end - def drop_current(environment = Rails.env) + def drop_current(environment = env) each_current_configuration(environment) { |configuration| drop configuration } @@ -113,7 +114,7 @@ module ActiveRecord drop database_url_config end - def charset_current(environment = Rails.env) + def charset_current(environment = env) charset ActiveRecord::Base.configurations[environment] end @@ -122,7 +123,7 @@ module ActiveRecord class_for_adapter(configuration['adapter']).new(*arguments).charset end - def collation_current(environment = Rails.env) + def collation_current(environment = env) collation ActiveRecord::Base.configurations[environment] end |