protected_attributes_continued 1.2.2 → 1.2.3

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
  SHA1:
3
- metadata.gz: e24f2d412ba2e3b374a7efc477bc513c985ce9a4
4
- data.tar.gz: c6205879e46a4fd1ff6e86cb21e604cb825b79f0
3
+ metadata.gz: 0b6d06c9ecd345f54b7136e67b717a90712ee240
4
+ data.tar.gz: b00b7d6f1387c84804247d7219a6ca6bb38a0157
5
5
  SHA512:
6
- metadata.gz: 5ee718e2c2ee7d6e417d6a159055f222f69ef5fb5aa7ddbed3d575ad30a154aaa7b9a98e624c24ae94f9a801ee68499e3142872e8c9e9c67d2ff23d35e9bf5f3
7
- data.tar.gz: acfc78413e07de4f486a7ad1d8c4aa33f85726683bbd5f0860838e1cfaaf60e00ad56b594d56f3c15dd844de28402291f5a435d07ff758c0fa88cb83c643a517
6
+ metadata.gz: 06fcac1475f0ceb85717733847aadf0a377b83cb5a2e94f9d36b8007315b4322020d9a386ae584e990e7e0aeaa928d7c3005093c1d0188b60f2cea59e87e4c66
7
+ data.tar.gz: 84651f941e29bb0257a052d6c8feec3548851f3e1eebcb6948aa7f01b8beacffb2b76622be5d84a843b3f4ab3bb7eb1453d9f6b3b4ac3d76a13a21e07e6a2f82
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Build Status](https://api.travis-ci.org/westonganger/protected_attributes_continued.svg?branch=master)](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. It already works perfectly fine with Rails 5 it just needed the dependencies relaxed. For people who would like to continue using this feature in their Rails 5 apps lets continue the development here. The original `protected_attributes` was officially supported by the Rails team until the release of Rails 5.0.
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
- unless attributes_collection.is_a?(Hash) || attributes_collection.is_a?(Array)
80
- raise ArgumentError, "Hash or Array expected, got #{attributes_collection.class.name} (#{attributes_collection.inspect})"
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 {|a| a['id'] || a[:id] }.compact
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
 
@@ -1,3 +1,3 @@
1
1
  module ProtectedAttributes
2
- VERSION = "1.2.2"
2
+ VERSION = "1.2.3"
3
3
  end
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.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-08-23 00:00:00.000000000 Z
12
+ date: 2016-09-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel