accepts_nested_attributes_for_public_id 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f30d194a7b2fb866d90ad1f136123a1778941ff1fd48105f1a4068e667110884
|
4
|
+
data.tar.gz: f60c0932253ce1879bcb0d187866edf6b530944ffa2221e471857ee62fd820a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3e83a88567e8550394ced1c5220cd876f8f14172a282ba2803a5474af62e3c95bb0e54bcc39a6145fb0c588247bb8a36c1d10911c97e9b9097e5a89cbf8fef5
|
7
|
+
data.tar.gz: b47a373d9ecbb65f78f181afb61c7ee5ee3bc7c318fe71589aa5cc090861dc86d064e691ced318c13fee30f886304af410a74e72738557fecfca39d5749b788a
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
3
|
- **Unreleased**
|
4
|
-
* [View Diff](https://github.com/westonganger/accepts_nested_attributes_for_public_id/compare/v1.0.
|
4
|
+
* [View Diff](https://github.com/westonganger/accepts_nested_attributes_for_public_id/compare/v1.0.1...master)
|
5
5
|
* Nothing yet
|
6
6
|
|
7
|
+
- **v1.0.1**
|
8
|
+
* [View Diff](https://github.com/westonganger/accepts_nested_attributes_for_public_id/compare/v1.0.0...v1.0.1)
|
9
|
+
* Add a couple allowed method contract violations for Rails 6.1 and below
|
10
|
+
* Resolve filter_map usage for compatibility with Ruby 2.6 and below
|
11
|
+
|
7
12
|
- **v1.0.0**
|
8
13
|
* Initial gem release
|
@@ -1,7 +1,13 @@
|
|
1
1
|
module AcceptsNestedAttributesForPublicId
|
2
|
+
ALLOWED_VIOLATIONS = [
|
3
|
+
->(method) { Rails::VERSION::MAJOR < 7 && method.name == :assign_nested_attributes_for_collection_association }, ### small change from `map.compact` to `filter_map`
|
4
|
+
->(method) { Rails::VERSION::MAJOR < 7 && method.name == :fields_for_with_nested_attributes }, ### small syntax change
|
5
|
+
]
|
6
|
+
|
2
7
|
def verify_method_contract!(method, contract)
|
3
8
|
if method.source.strip.gsub(/^\s*/, "") != contract.strip.gsub(/^\s*/, "")
|
4
|
-
|
9
|
+
return if ALLOWED_VIOLATIONS.any?{|x| x.call(method) }
|
10
|
+
raise RuntimeError.new("Method definition contract violated for '#{method.owner}##{method.name}', cannot apply patch for accepts_nested_attributes_for_public_id")
|
5
11
|
end
|
6
12
|
end
|
7
13
|
module_function :verify_method_contract!
|
@@ -188,7 +188,7 @@ ActiveSupport.on_load(:active_record) do
|
|
188
188
|
existing_records = if association.loaded?
|
189
189
|
association.target
|
190
190
|
else
|
191
|
-
attribute_ids = attributes_collection.
|
191
|
+
attribute_ids = attributes_collection.map { |a| a["id"] || a[:id] }.compact
|
192
192
|
### ORIGINAL
|
193
193
|
# attribute_ids.empty? ? [] : association.scope.where(association.klass.primary_key => attribute_ids)
|
194
194
|
### NEW
|