Last active
August 15, 2016 20:39
-
-
Save IanWhitney/d0ed6fb4b79f56eb82d6aa9bd645de8f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module DataViews | |
def self.root | |
@root ||= File.expand_path(File.join("..", ".."), __FILE__) | |
end | |
def self.environment | |
@environment ||= Rails.env || "development" | |
end | |
def self.environment=(other) | |
@environment = other | |
end | |
end | |
require_relative "../config/initializers/peoplesoft_models" | |
require_relative "../config/initializers/data_views" | |
require "view_builder" | |
Dir.glob(File.join(File.dirname(__FILE__), "data_views", "**", "*.rb")) { |file| require file } | |
#---- | |
require "active_record" | |
include ActiveRecord::Tasks | |
DatabaseTasks.root = begin | |
DataViews.root | |
rescue NameError | |
Rails.root | |
end | |
DatabaseTasks.env = begin | |
DataViews.environment | |
rescue NameError | |
Rails.env | |
end | |
DatabaseTasks.db_dir = File.join(DatabaseTasks.root, "/db") | |
DatabaseTasks.database_configuration = YAML.load(File.read(File.join(DatabaseTasks.root, "config", "database.yml"))) | |
DatabaseTasks.migrations_paths = File.join(DatabaseTasks.db_dir, "migrations") | |
ActiveRecord::Base.configurations = DatabaseTasks.database_configuration | |
ActiveRecord::Base.establish_connection DatabaseTasks.env.to_sym | |
require 'data_views' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment