diff --git a/lib/polyamorous/polyamorous.rb b/lib/polyamorous/polyamorous.rb index f1b759d2..0d361543 100644 --- a/lib/polyamorous/polyamorous.rb +++ b/lib/polyamorous/polyamorous.rb @@ -1,4 +1,4 @@ -if defined?(::ActiveRecord) +ActiveSupport.on_load(:active_record) do module Polyamorous InnerJoin = Arel::Nodes::InnerJoin OuterJoin = Arel::Nodes::OuterJoin diff --git a/lib/ransack.rb b/lib/ransack.rb index 1a88b646..1b72af5e 100644 --- a/lib/ransack.rb +++ b/lib/ransack.rb @@ -1,3 +1,11 @@ +require 'active_support/dependencies/autoload' +require 'active_support/deprecation' +require 'active_support/version' + +if ::ActiveSupport.version >= ::Gem::Version.new("7.1") + require 'active_support/deprecator' +end + require 'active_support/core_ext' require 'ransack/configuration' require 'polyamorous/polyamorous' diff --git a/lib/ransack/helpers/form_builder.rb b/lib/ransack/helpers/form_builder.rb index 0f9d826f..54bbb275 100644 --- a/lib/ransack/helpers/form_builder.rb +++ b/lib/ransack/helpers/form_builder.rb @@ -6,13 +6,12 @@ module ActionView::Helpers::Tags # https://github.com/rails/rails/commit/c1a118a class Base private - if defined? ::ActiveRecord - def value - if @allow_method_names_outside_object - object.send @method_name if object && object.respond_to?(@method_name, true) - else - object.send @method_name if object - end + + def value + if @allow_method_names_outside_object + object.send @method_name if object && object.respond_to?(@method_name, true) + else + object.send @method_name if object end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0c4bf109..18facc43 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,13 +1,12 @@ -require 'machinist/active_record' -require 'polyamorous/polyamorous' +require 'ransack' require 'sham' require 'faker' -require 'ransack' require 'action_controller' require 'ransack/helpers' require 'pry' require 'simplecov' require 'byebug' +require 'machinist/active_record' SimpleCov.start I18n.enforce_available_locales = false