From c370c8fa8c66d5b0bf7d7b26bbed95807ee8f126 Mon Sep 17 00:00:00 2001 From: Kevin Bruccoleri Date: Mon, 9 Sep 2024 12:28:56 -0400 Subject: [PATCH 1/3] Monkey-patch in assign_nested_parameter_attributes function It is has been removed from ActiveRecord 7.2.x https://github.com/rails/rails/pull/49678/ --- .../mass_assignment_security/attribute_assignment.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/active_record/mass_assignment_security/attribute_assignment.rb b/lib/active_record/mass_assignment_security/attribute_assignment.rb index 972391f..7385e0d 100644 --- a/lib/active_record/mass_assignment_security/attribute_assignment.rb +++ b/lib/active_record/mass_assignment_security/attribute_assignment.rb @@ -84,6 +84,11 @@ def assign_attributes(new_attributes, options = {}) protected + # This function has been removed from ActiveRecord 7.2.x, so we monkey-patch it back in + def assign_nested_parameter_attributes(pairs) + pairs.each { |k, v| _assign_attribute(k, v) } + end + def mass_assignment_options @mass_assignment_options ||= {} end From 80cbe165b8632d75d85c93e14b18c0742f12b55a Mon Sep 17 00:00:00 2001 From: Kevin Bruccoleri Date: Mon, 9 Sep 2024 12:54:16 -0400 Subject: [PATCH 2/3] Update version and gemspec compatibility --- lib/protected_attributes/version.rb | 2 +- protected_attributes_continued.gemspec | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/protected_attributes/version.rb b/lib/protected_attributes/version.rb index 15d8a1c..312d6be 100644 --- a/lib/protected_attributes/version.rb +++ b/lib/protected_attributes/version.rb @@ -1,3 +1,3 @@ module ProtectedAttributes - VERSION = "1.9.0".freeze + VERSION = "1.10.0".freeze end diff --git a/protected_attributes_continued.gemspec b/protected_attributes_continued.gemspec index 132e102..ebbdfc7 100644 --- a/protected_attributes_continued.gemspec +++ b/protected_attributes_continued.gemspec @@ -16,10 +16,10 @@ Gem::Specification.new do |gem| gem.files = Dir["LICENSE.txt", "README.md", "lib/**/*"] gem.require_paths = ["lib"] - gem.add_dependency "activemodel", ">= 5.0", "< 7" + gem.add_dependency "activemodel", ">= 5.0", "< 8" - gem.add_development_dependency "activerecord", ">= 5.0", "< 7" - gem.add_development_dependency "actionpack", ">= 5.0", "< 7" - gem.add_development_dependency "railties", ">= 5.0", "< 7" + gem.add_development_dependency "activerecord", ">= 5.0", "< 8" + gem.add_development_dependency "actionpack", ">= 5.0", "< 8" + gem.add_development_dependency "railties", ">= 5.0", "< 8" gem.add_development_dependency "mocha", "~> 1.4.0" end From 24a86f98427879a059867717fc07dbe58f62008d Mon Sep 17 00:00:00 2001 From: David Date: Tue, 10 Dec 2024 17:30:04 -0500 Subject: [PATCH 3/3] Need `@mutex` to call synchronize - Reflected in rails https://github.com/rails/rails/blob/main/actionpack/lib/action_controller/metal/params_wrapper.rb#L112 --- lib/action_controller/accessible_params_wrapper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/action_controller/accessible_params_wrapper.rb b/lib/action_controller/accessible_params_wrapper.rb index d1cc8a8..376de79 100644 --- a/lib/action_controller/accessible_params_wrapper.rb +++ b/lib/action_controller/accessible_params_wrapper.rb @@ -11,7 +11,7 @@ def include return super if @include_set m = model - synchronize do + @mutex.synchronize do return super if @include_set @include_set = true