protected_attributes_continued 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b6d06c9ecd345f54b7136e67b717a90712ee240
|
4
|
+
data.tar.gz: b00b7d6f1387c84804247d7219a6ca6bb38a0157
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06fcac1475f0ceb85717733847aadf0a377b83cb5a2e94f9d36b8007315b4322020d9a386ae584e990e7e0aeaa928d7c3005093c1d0188b60f2cea59e87e4c66
|
7
|
+
data.tar.gz: 84651f941e29bb0257a052d6c8feec3548851f3e1eebcb6948aa7f01b8beacffb2b76622be5d84a843b3f4ab3bb7eb1453d9f6b3b4ac3d76a13a21e07e6a2f82
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[](https://travis-ci.org/westonganger/protected_attributes_continued)
|
4
4
|
|
5
|
-
This is the community continued version of `protected_attributes`. I have created this new repo because the Rails team refuses to support the `protected_attributes` gem for Rails 5.
|
5
|
+
This is the community continued version of `protected_attributes`. I have created this new repo and changed the name because the Rails team refuses to support the `protected_attributes` gem for Rails 5. For people who would like to continue using this feature in their Rails 5 apps lets continue here. I am currently_using this successfully in number of Rails 5 production apps.
|
6
6
|
|
7
7
|
Protect attributes from mass-assignment in Active Record models.
|
8
8
|
|
@@ -76,8 +76,12 @@ module ActiveRecord
|
|
76
76
|
def assign_nested_attributes_for_collection_association(association_name, attributes_collection, assignment_opts = {})
|
77
77
|
options = self.nested_attributes_options[association_name]
|
78
78
|
|
79
|
-
|
80
|
-
|
79
|
+
class_name = attributes_collection.class.name
|
80
|
+
|
81
|
+
if class_name == 'ActionController::Parameters'
|
82
|
+
attributes_collection = attributes_collection.to_unsafe_h
|
83
|
+
elsif !['Hash','Array'].include?(class_name)
|
84
|
+
raise ArgumentError, "ActionController::Parameters or Hash or Array expected, got #{attributes_collection.class.name} (#{attributes_collection.inspect})"
|
81
85
|
end
|
82
86
|
|
83
87
|
if limit = options[:limit]
|
@@ -109,7 +113,7 @@ module ActiveRecord
|
|
109
113
|
existing_records = if association.loaded?
|
110
114
|
association.target
|
111
115
|
else
|
112
|
-
attribute_ids = attributes_collection.map
|
116
|
+
attribute_ids = attributes_collection.map{|a| a['id'] || a[:id] }.compact
|
113
117
|
attribute_ids.empty? ? [] : association.scope.where(association.klass.primary_key => attribute_ids)
|
114
118
|
end
|
115
119
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: protected_attributes_continued
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-09-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|