aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Gemfile2
-rw-r--r--config/initializers/apartment_null_db.rb34
2 files changed, 19 insertions, 17 deletions
diff --git a/Gemfile b/Gemfile
index 1cd5f818c..898293ac5 100644
--- a/Gemfile
+++ b/Gemfile
@@ -65,7 +65,7 @@ end
gem 'activerecord-postgis-adapter', "~> 3.0.0"
gem 'polylines'
-gem 'activerecord-nulldb-adapter'
+gem 'activerecord-nulldb-adapter', require: false
# Codifligne API
gem 'codifligne', af83: 'stif-codifline-api'
diff --git a/config/initializers/apartment_null_db.rb b/config/initializers/apartment_null_db.rb
index b50ec3ad9..796706cc2 100644
--- a/config/initializers/apartment_null_db.rb
+++ b/config/initializers/apartment_null_db.rb
@@ -1,24 +1,26 @@
-require 'apartment/adapters/abstract_adapter'
+if ENV['RAILS_DB_ADAPTER'] == 'nulldb'
+ require 'apartment/adapters/abstract_adapter'
-module Apartment
- module Tenant
- def adapter
- Thread.current[:apartment_adapter] ||= begin
- nulldb_adapter(config)
+ module Apartment
+ module Tenant
+ def adapter
+ Thread.current[:apartment_adapter] ||= begin
+ nulldb_adapter(config)
+ end
end
- end
- def self.nulldb_adapter(config)
- adapter = Adapters::NulldbAdapter
- adapter.new(config)
+ def self.nulldb_adapter(config)
+ adapter = Adapters::NulldbAdapter
+ adapter.new(config)
+ end
end
- end
- module Adapters
- # Default adapter when not using Postgresql Schemas
- class NulldbAdapter < AbstractAdapter
- def initialize config
- super
+ module Adapters
+ # Default adapter when not using Postgresql Schemas
+ class NulldbAdapter < AbstractAdapter
+ def initialize config
+ super
+ end
end
end
end