fix ActiveRecord ConnectionNotEstablished when ActiveRecord isnt required in a project
This commit is contained in:
parent
af0aed4414
commit
bc8996c04d
@ -1,8 +1,6 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
begin
|
if defined?(::ActiveRecord)
|
||||||
require 'active_record'
|
|
||||||
|
|
||||||
::ActiveRecord::Associations::Builder::HasOne.class_eval do
|
::ActiveRecord::Associations::Builder::HasOne.class_eval do
|
||||||
# Based on
|
# Based on
|
||||||
# https://github.com/rails/rails/blob/master/activerecord/lib/active_record/associations/builder/collection_association.rb#L50
|
# https://github.com/rails/rails/blob/master/activerecord/lib/active_record/associations/builder/collection_association.rb#L50
|
||||||
@ -17,6 +15,4 @@ begin
|
|||||||
CODE
|
CODE
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue LoadError
|
|
||||||
# active_record can't be loaded so we shouldn't try to monkey-patch it.
|
|
||||||
end
|
end
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
require 'active_record'
|
||||||
require 'fast_jsonapi'
|
require 'fast_jsonapi'
|
||||||
require 'rspec-benchmark'
|
require 'rspec-benchmark'
|
||||||
require 'byebug'
|
require 'byebug'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user