Skip to content

Commit

Permalink
fix: add nulldb connector and no more db connection for assets precom…
Browse files Browse the repository at this point in the history
…pile
  • Loading branch information
yksflip committed Aug 23, 2023
1 parent 1e63c59 commit 10b67de
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,5 @@ group :test do
# api
gem 'rswag-specs'
end

gem "activerecord-nulldb-adapter", "~> 0.9.0"
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ GEM
activerecord (7.0.4)
activemodel (= 7.0.4)
activesupport (= 7.0.4)
activerecord-nulldb-adapter (0.9.0)
activerecord (>= 5.2.0, < 7.1)
activestorage (7.0.4)
actionpack (= 7.0.4)
activejob (= 7.0.4)
Expand Down Expand Up @@ -605,6 +607,7 @@ PLATFORMS

DEPENDENCIES
active_model_serializers (~> 0.10.0)
activerecord-nulldb-adapter (~> 0.9.0)
acts_as_tree
acts_as_versioned!
apparition
Expand Down
2 changes: 1 addition & 1 deletion app/lib/foodsoft_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def select_multifoodcoop(foodcoop)
# @param key [String, Symbol]
# @return [Object] Value of the key.
def [](key)
if RailsSettings::CachedSettings.table_exists? && allowed_key?(key)
if ActiveRecord::Base.connected? && RailsSettings::CachedSettings.table_exists? && allowed_key?(key)
value = RailsSettings::CachedSettings["foodcoop.#{scope}.#{key}"]
value = config[key] if value.nil?
value
Expand Down
4 changes: 0 additions & 4 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ class Application < Rails::Application
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'

# It would be nice not to enable database connection when precompiling assets,
# but i18n-js requires initialization, that's why it's on.
config.assets.initialize_on_precompile = true

# Load legacy scripts from vendor
config.assets.precompile += ['vendor/assets/javascripts/*.js']

Expand Down
2 changes: 2 additions & 0 deletions config/database.yml.NULLDB_SAMPLE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test:
adapter: nulldb

0 comments on commit 10b67de

Please sign in to comment.