Sha256: ba135c83cdf56e7e199927de20cdb615c1cd2ee5eef397dbdd4652f9f0f6eea1

Contents?: true

Size: 737 Bytes

Versions: 1

Compression:

Stored size: 737 Bytes

Contents

require 'active_record'

module DbRemote
  def initialize(opts={})
    raise "Aborting: no database.yml file found" unless opts[:rails]
    Rails.root = opts[:rails]
    yml_path = File.join(Rails.root, "config/database.yml") # hard-coding the location of the yml file
    dbconfig = YAML::load(ERB.new(File.open(yml_path).read).result(binding))
    # hard-coding AR
    ActiveRecord::Base.establish_connection dbconfig["development"] # hard-coding the environment
    super()
  end
  
  def connection
    ActiveRecord::Base.connection
  end
  
  # faking out the branch-name detection in database.yml. we may want to integrate with Rails later.
  module Rails
    def self.root; @@root end
    def self.root=(x); @@root=x end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hydroponics-0.2.2 lib/db_remote.rb