Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add establish connection to the alias hijacking. #427

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 5 additions & 2 deletions lib/octopus/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ class << self
alias_method :connected_without_octopus?, :connected?
alias_method :connected?, :connected_with_octopus?

alias_method :establish_connection_without_octopus, :establish_connection
alias_method :establish_connection, :establish_connection_with_octopus

def table_name=(value = nil)
self.custom_octopus_table_name = true
super
Expand Down Expand Up @@ -184,9 +187,9 @@ def set_table_name_with_octopus(value = nil, &block)
set_table_name_without_octopus(value, &block)
end

def octopus_establish_connection(spec = ENV['DATABASE_URL'])
def establish_connection_with_octopus(spec = ENV['DATABASE_URL'])
self.custom_octopus_connection = true if spec
establish_connection(spec)
establish_connection_without_octopus(spec)
end

def octopus_set_table_name(value = nil)
Expand Down