diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-09-12 20:18:34 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-09-12 20:18:34 -0300 |
commit | 2cde98c8cac8415a23eecc14a9757e07cb7c3f47 (patch) | |
tree | 8ec99d797259b0ca8035271b9a0c6590b53dc941 | |
parent | 4aa89eda065eb8d1ed16df72804c15a1a41719fa (diff) | |
parent | 44249b29e74e3c87755163532174ba30df580eed (diff) | |
download | rails-2cde98c8cac8415a23eecc14a9757e07cb7c3f47.tar.gz rails-2cde98c8cac8415a23eecc14a9757e07cb7c3f47.tar.bz2 rails-2cde98c8cac8415a23eecc14a9757e07cb7c3f47.zip |
Merge pull request #11698 from dmathieu/sqlite_tasks_without_rails
Let the SQLite rake tasks run without rails
-rw-r--r-- | activerecord/lib/active_record/railtie.rb | 1 | ||||
-rw-r--r-- | activerecord/lib/active_record/tasks/database_tasks.rb | 3 | ||||
-rw-r--r-- | activerecord/lib/active_record/tasks/sqlite_database_tasks.rb | 2 |
3 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/railtie.rb b/activerecord/lib/active_record/railtie.rb index 269f9f975b..eef08aea88 100644 --- a/activerecord/lib/active_record/railtie.rb +++ b/activerecord/lib/active_record/railtie.rb @@ -46,6 +46,7 @@ module ActiveRecord ActiveRecord::Tasks::DatabaseTasks.database_configuration = Rails.application.config.database_configuration ActiveRecord::Tasks::DatabaseTasks.migrations_paths = Rails.application.paths['db/migrate'].to_a ActiveRecord::Tasks::DatabaseTasks.fixtures_path = File.join Rails.root, 'test', 'fixtures' + ActiveRecord::Tasks::DatabaseTasks.root = Rails.root if defined?(ENGINE_PATH) && engine = Rails::Engine.find(ENGINE_PATH) if engine.paths['db/migrate'].existent diff --git a/activerecord/lib/active_record/tasks/database_tasks.rb b/activerecord/lib/active_record/tasks/database_tasks.rb index 5ff594fdca..b91bbeb412 100644 --- a/activerecord/lib/active_record/tasks/database_tasks.rb +++ b/activerecord/lib/active_record/tasks/database_tasks.rb @@ -23,6 +23,7 @@ module ActiveRecord # * +fixtures_path+: a path to fixtures directory. # * +migrations_paths+: a list of paths to directories with migrations. # * +seed_loader+: an object which will load seeds, it needs to respond to the +load_seed+ method. + # * +root+: a path to the root of the application. # # Example usage of +DatabaseTasks+ outside Rails could look as such: # @@ -37,7 +38,7 @@ module ActiveRecord attr_writer :current_config attr_accessor :database_configuration, :migrations_paths, :seed_loader, :db_dir, - :fixtures_path, :env + :fixtures_path, :env, :root LOCAL_HOSTS = ['127.0.0.1', 'localhost'] diff --git a/activerecord/lib/active_record/tasks/sqlite_database_tasks.rb b/activerecord/lib/active_record/tasks/sqlite_database_tasks.rb index de8b16627e..5688931db2 100644 --- a/activerecord/lib/active_record/tasks/sqlite_database_tasks.rb +++ b/activerecord/lib/active_record/tasks/sqlite_database_tasks.rb @@ -3,7 +3,7 @@ module ActiveRecord class SQLiteDatabaseTasks # :nodoc: delegate :connection, :establish_connection, to: ActiveRecord::Base - def initialize(configuration, root = Rails.root) + def initialize(configuration, root = ActiveRecord::Tasks::DatabaseTasks.root) @configuration, @root = configuration, root end |