aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Gemfile1
-rw-r--r--Gemfile.lock5
-rw-r--r--config/initializers/apartment_null_db.rb25
3 files changed, 30 insertions, 1 deletions
diff --git a/Gemfile b/Gemfile
index 21f534c8b..1cd5f818c 100644
--- a/Gemfile
+++ b/Gemfile
@@ -65,6 +65,7 @@ end
gem 'activerecord-postgis-adapter', "~> 3.0.0"
gem 'polylines'
+gem 'activerecord-nulldb-adapter'
# Codifligne API
gem 'codifligne', af83: 'stif-codifline-api'
diff --git a/Gemfile.lock b/Gemfile.lock
index f9682dff1..27d3c18eb 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -75,6 +75,8 @@ GEM
activemodel (= 4.2.8)
activesupport (= 4.2.8)
arel (~> 6.0)
+ activerecord-nulldb-adapter (0.3.7)
+ activerecord (>= 2.0.0)
activerecord-postgis-adapter (3.0.0)
activerecord (~> 4.2)
rgeo-activerecord (~> 4.0)
@@ -566,6 +568,7 @@ DEPENDENCIES
SyslogLogger
aasm
active_attr
+ activerecord-nulldb-adapter
activerecord-postgis-adapter (~> 3.0.0)
acts-as-taggable-on (~> 4.0.0)
acts_as_list (~> 0.6.0)
@@ -683,4 +686,4 @@ DEPENDENCIES
will_paginate-bootstrap
BUNDLED WITH
- 1.15.4
+ 1.16.0
diff --git a/config/initializers/apartment_null_db.rb b/config/initializers/apartment_null_db.rb
new file mode 100644
index 000000000..b50ec3ad9
--- /dev/null
+++ b/config/initializers/apartment_null_db.rb
@@ -0,0 +1,25 @@
+require 'apartment/adapters/abstract_adapter'
+
+module Apartment
+ module Tenant
+ def adapter
+ Thread.current[:apartment_adapter] ||= begin
+ nulldb_adapter(config)
+ end
+ end
+
+ def self.nulldb_adapter(config)
+ adapter = Adapters::NulldbAdapter
+ adapter.new(config)
+ end
+ end
+
+ module Adapters
+ # Default adapter when not using Postgresql Schemas
+ class NulldbAdapter < AbstractAdapter
+ def initialize config
+ super
+ end
+ end
+ end
+end