diff --git a/Gemfile b/Gemfile index ac31ad3..a11525c 100644 --- a/Gemfile +++ b/Gemfile @@ -6,7 +6,7 @@ gem "debug" if (rails_version = ENV["RAILS_VERSION"]) gem "rails", "~> #{rails_version}" else - gem "rails" + gem "rails", "7.0.8.4" end gem "syntax_tree" gem "typeprof" diff --git a/lib/hoardable/has_one.rb b/lib/hoardable/has_one.rb index ef9843c..a31c87b 100644 --- a/lib/hoardable/has_one.rb +++ b/lib/hoardable/has_one.rb @@ -10,10 +10,8 @@ def has_one(*args) options = args.extract_options! hoardable = options.delete(:hoardable) name = args.first - has_one_options = super(*args, **options)[name]&.options - unless hoardable || (has_one_options && has_one_options[:class_name].match?(/RichText$/)) - return - end + association = super(*args, **options).symbolize_keys[name] + return unless hoardable || (association.options[:class_name].match?(/RichText$/)) class_eval <<-RUBY, __FILE__, __LINE__ + 1 def #{name} diff --git a/test/test_schema_dumper.rb b/test/test_schema_dumper.rb index 84a424c..034ac57 100644 --- a/test/test_schema_dumper.rb +++ b/test/test_schema_dumper.rb @@ -32,7 +32,11 @@ class TestSchemaDumper < ActiveSupport::TestCase private def dump_table_schema(*table_names) connection = ActiveRecord::Base.connection ActiveRecord::SchemaDumper.ignore_tables = connection.data_sources - table_names - output, = capture_io { ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection_pool) } - output + if ActiveRecord.version >= Gem::Version.new("7.2.1") + output, = capture_io { ActiveRecord::SchemaDumper.dump(ActiveRecord::Base.connection_pool) } + output + else + ActiveRecord::SchemaDumper.dump(connection, StringIO.new).string + end end end