diff --git a/lib/hijacker.rb b/lib/hijacker.rb index 4fe998e..e0f5494 100644 --- a/lib/hijacker.rb +++ b/lib/hijacker.rb @@ -187,13 +187,14 @@ def self.root_config end def self.database_configurations - ActiveRecord::Base.configurations + ActiveRecord::Base.configurations = YAML.load(File.read('config/database.yml')) end # this should establish a connection to a database containing the bare minimum # for loading the app, usually a sessions table if using sql-based sessions. def self.establish_root_connection - ActiveRecord::Base.establish_connection('root') + @dbconfig = YAML.load(File.read('config/database.yml')) + ActiveRecord::Base.establish_connection @dbconfig['root'] end def self.processing_sister_site? diff --git a/lib/hijacker/base_model.rb b/lib/hijacker/base_model.rb index f2abb42..08c3063 100644 --- a/lib/hijacker/base_model.rb +++ b/lib/hijacker/base_model.rb @@ -1,6 +1,6 @@ module Hijacker class BaseModel < ActiveRecord::Base - establish_connection('root') + establish_connection(:root) self.abstract_class = true end diff --git a/lib/hijacker/database.rb b/lib/hijacker/database.rb index a6c8248..1a43579 100644 --- a/lib/hijacker/database.rb +++ b/lib/hijacker/database.rb @@ -59,7 +59,7 @@ def self.find_by_name(name) end def self.current - find(:first, :conditions => {:database => Hijacker.current_client}) + find_by(database: Hijacker.current_client) end # returns a string or nil diff --git a/lib/hijacker/host.rb b/lib/hijacker/host.rb index b082e53..78828c2 100644 --- a/lib/hijacker/host.rb +++ b/lib/hijacker/host.rb @@ -1,6 +1,6 @@ class Hijacker::Host < Hijacker::BaseModel - validates_format_of :hostname, :with => /^(#{URI::REGEXP::PATTERN::HOST}|#{URI::REGEXP::PATTERN::IPV6ADDR})$/ + validates_format_of :hostname, :with => /\A(#{URI::REGEXP::PATTERN::HOST}|#{URI::REGEXP::PATTERN::IPV6ADDR})\z/ belongs_to :slave, class_name: "Hijacker::Host" end