diff options
| author | Zog | 2017-12-20 08:52:57 +0100 | 
|---|---|---|
| committer | Zog | 2017-12-20 09:02:57 +0100 | 
| commit | 477f98b1508796a53870e00a192ff47875c5907c (patch) | |
| tree | c7ac8bf6116810953ad067fbbfbc2b78193e339e | |
| parent | e7bece2f871d51ad71ee2ee258afd985bf8d8485 (diff) | |
| download | chouette-core-477f98b1508796a53870e00a192ff47875c5907c.tar.bz2 | |
Refs #5334@3h; Add support fort NullDB in Apartment
This will allow us to compile assets with a null_db adapter.
| -rw-r--r-- | Gemfile | 1 | ||||
| -rw-r--r-- | Gemfile.lock | 5 | ||||
| -rw-r--r-- | config/initializers/apartment_null_db.rb | 25 | 
3 files changed, 30 insertions, 1 deletions
| @@ -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 | 
