Sha256: 24ad9dcc06ec8168f5eddadc0beb325eac0ad4ecd5e2c1e7b78da02fbebc31ed

Contents?: true

Size: 1.97 KB

Versions: 47

Compression:

Stored size: 1.97 KB

Contents

#################
##     SETTINGS FOR DATABASES
#
# this file contains common settings and rake tasks for ORM gems.
#
# please review / edit the settings you need.
# 
############
## ActiveRecord without Rails
# more info at:
# https://www.youtube.com/watch?v=o0SzhgYntK8
# demo code here:
# https://github.com/stungeye/ActiveRecord-without-Rails
if defined? ActiveRecord
	puts "Loading ActiveRecord database setting: #{ENV['ENV']}"
	ActiveRecord::Base.establish_connection(  YAML::load(  File.open( Root.join('db', 'config.yml').to_s )  )[ ENV["ENV"].to_s ]  )

	# if debugging purposes, uncomment this line to see the ActiveRecord's generated SQL:
	# ActiveRecord::Base.logger = Plezi.logger

	# Uncomment this line to make the logger output look nicer in Windows.
	# ActiveSupport::LogSubscriber.colorize_logging = false

	# Load ActiveRecord Tasks, if implemented
	if defined? Rake

		begin
			require 'standalone_migrations'
			StandaloneMigrations::Tasks.load_tasks
		rescue Exception => e
			ActiveRecord::Tasks::DatabaseTasks.env = ENV['ENV'] || 'development'
			ActiveRecord::Tasks::DatabaseTasks.database_configuration = YAML.load(File.read(Root.join('db', 'config.yml').to_s))
			ActiveRecord::Tasks::DatabaseTasks.db_dir = Root.join('db').to_s
			ActiveRecord::Tasks::DatabaseTasks.fixtures_path = Root.join( 'db', 'fixtures').to_s
			ActiveRecord::Tasks::DatabaseTasks.migrations_paths = [Root.join('db', 'migrate').to_s]
			ActiveRecord::Tasks::DatabaseTasks.seed_loader = Class.new do
				def self.load_seed
					filename = Root.join('db', 'seeds.rb').to_s
					unless File.file?(filename)
						IO.write filename, ''
					end
					load filename
				end
			end
			ActiveRecord::Tasks::DatabaseTasks.root = Root.to_s

			task :environment do
				ActiveRecord::Base.configurations = ActiveRecord::Tasks::DatabaseTasks.database_configuration
				ActiveRecord::Base.establish_connection ActiveRecord::Tasks::DatabaseTasks.env.to_sym
			end

			load 'active_record/railties/databases.rake'

		end
	end


end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
plezi-0.12.22 resources/db_ac_config.rb
plezi-0.12.21 resources/db_ac_config.rb
plezi-0.12.20 resources/db_ac_config.rb
plezi-0.12.19 resources/db_ac_config.rb
plezi-0.12.18 resources/db_ac_config.rb
plezi-0.12.17 resources/db_ac_config.rb
plezi-0.12.16 resources/db_ac_config.rb
plezi-0.12.15 resources/db_ac_config.rb
plezi-0.12.14 resources/db_ac_config.rb
plezi-0.12.13 resources/db_ac_config.rb
plezi-0.12.11 resources/db_ac_config.rb
plezi-0.12.10 resources/db_ac_config.rb
plezi-0.12.9 resources/db_ac_config.rb
plezi-0.12.8 resources/db_ac_config.rb
plezi-0.12.7 resources/db_ac_config.rb
plezi-0.12.6 resources/db_ac_config.rb
plezi-0.12.5 resources/db_ac_config.rb
plezi-0.12.4 resources/db_ac_config.rb
plezi-0.12.3 resources/db_ac_config.rb
plezi-0.12.2 resources/db_ac_config.rb