Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/hijacker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
2 changes: 1 addition & 1 deletion lib/hijacker/base_model.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Hijacker
class BaseModel < ActiveRecord::Base
establish_connection('root')
establish_connection(:root)

self.abstract_class = true
end
Expand Down
2 changes: 1 addition & 1 deletion lib/hijacker/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/hijacker/host.rb
Original file line number Diff line number Diff line change
@@ -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