Skip to content

Commit 195be6d

Browse files
committed
fix: prevent establishing ActiveRecord connection on startup
Instead of creating a connection and looking at its database adapter, look at the configured adapter instead. This prevents issues when trying to compile assets or running other rake tasks in `RAILS_ENV=production` that are supposed to work without a running database.
1 parent f3008c6 commit 195be6d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/ajax-datatables-rails/base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module AjaxDatatablesRails
44
class Base
55

6-
class_attribute :db_adapter, default: ::ActiveRecord::Base.connection.adapter_name.downcase.to_sym
6+
class_attribute :db_adapter, default: ::ActiveRecord::Base.configurations.configs_for(env_name: Rails.env).first.adapter.downcase.to_sym
77
class_attribute :nulls_last, default: false
88

99
attr_reader :params, :options, :datatable

0 commit comments

Comments
 (0)