12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/topological_inventory/core/ar_helper.rb', line 12
def self.load_environment!
ENV["RAILS_ENV"] ||= "development"
require "yaml"
database_yaml = YAML.load_file(database_yaml_path) if database_yaml_path.exist?
require "active_record"
ActiveRecord::Tasks::DatabaseTasks.env = ENV["RAILS_ENV"]
ActiveRecord::Tasks::DatabaseTasks.database_configuration = database_yaml || {}
ActiveRecord::Tasks::DatabaseTasks.db_dir = root.join("db")
ActiveRecord::Tasks::DatabaseTasks.migrations_paths = [root.join("db/migrate")]
autoload_models
require "topological_inventory/core/seed_loader"
ActiveRecord::Tasks::DatabaseTasks.seed_loader = TopologicalInventory::Core::SeedLoader
ActiveRecord::Tasks::DatabaseTasks.root = root
ActiveRecord::Base.configurations = ActiveRecord::Tasks::DatabaseTasks.database_configuration
ActiveRecord::Base.establish_connection(ENV["RAILS_ENV"].to_sym)
end
|