lib/sequel_rails/railtie.rb in sequel-rails-1.1.1 vs lib/sequel_rails/railtie.rb in sequel-rails-1.2.0
- old
+ new
@@ -13,11 +13,10 @@
require 'sequel_rails/configuration'
require 'sequel_rails/migrations'
require 'sequel_rails/railties/log_subscriber'
require 'sequel_rails/railties/i18n_support'
-require 'sequel_rails/railties/spring_support'
require 'sequel_rails/railties/controller_runtime'
require 'sequel_rails/sequel/database/active_support_notification'
require 'action_dispatch/middleware/session/sequel_store'
module SequelRails
@@ -74,23 +73,21 @@
initializer 'sequel.connect' do |app|
::SequelRails.setup(::Rails.env) if database_connection_required?(app)
end
initializer 'sequel.spring' do |_app|
- if defined?(::Spring::Application)
- class ::Spring::Application # rubocop:disable Style/ClassAndModuleChildren
- include ::SequelRails::SpringSupport
- alias_method :disconnect_database_without_sequel, :disconnect_database
- alias_method :disconnect_database, :disconnect_database_with_sequel
- end
- end
+ Spring.after_fork { Sequel::DATABASES.each(&:disconnect) } if defined?(Spring)
end
# Support overwriting crucial steps in subclasses
def configure_sequel(app)
rails_db_config = begin
app.config.database_configuration
+ rescue RuntimeError => e
+ raise unless e.message =~ /Cannot load database configuration/
+
+ {} # will try to use DATABASE_URL
rescue Errno::ENOENT
{} # will try to use DATABASE_URL
end
app.config.sequel.merge!(
@@ -117,9 +114,9 @@
def database_connection_required?(app)
!app.config.sequel[:skip_connect]
end
def database_create_command?
- ["db:create", "db:create:all"].any? { |c| ARGV.include?(c) }
+ ['db:create', 'db:create:all'].any? { |c| ARGV.include?(c) }
end
end
end