moderate_parameters 0.3.2 → 0.3.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 +4 -4
- data/README.md +14 -1
- data/lib/moderate_parameters/parameters.rb +6 -0
- data/lib/moderate_parameters/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eadf86f5451aa4174775854ab8a06f333df6f8a1a5a488b2243c918c8dcd3b0e
|
4
|
+
data.tar.gz: e5fd0011f7e56fd2962048b164be839ff3b6884816984376eb2b645ab796cf73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6466402a390cc33148e0aed8227136af9ce60938d2f393d74c53e56814febae9802de2d9f0d407b76aaf4787b55237fe06cf7332b79e7b822aae84aae943e04
|
7
|
+
data.tar.gz: 1a56422b48b5111e4616310acf87f254ba899637696e52d8951df9e1eaf7462663184546f061689b08f31483a0bb30a969405e1c46a406e89211499b5b197988
|
data/README.md
CHANGED
@@ -5,6 +5,8 @@
|
|
5
5
|
|
6
6
|
By [Hint.io](https://hint.io)
|
7
7
|
|
8
|
+
[](https://badge.fury.io/rb/moderate_parameters) [](https://circleci.com/gh/hintmedia/moderate_parameters) [](https://codeclimate.com/github/hintmedia/moderate_parameters/maintainability)
|
9
|
+
|
8
10
|
In our experience with [UpgradeRails](https://www.upgraderails.com), the migration from [protected_attributes](https://github.com/rails/protected_attributes) to [strong_parameters](https://api.rubyonrails.org/classes/ActionController/StrongParameters.html) can leave more questions than answers. It can be difficult to determine what data is originating from within the app and what is coming from the internet.
|
9
11
|
|
10
12
|
Moderate Parameters is a set of tools providing logging of data sources in the controller by extending `ActionController::Parameters` functionality.
|
@@ -111,7 +113,7 @@ end
|
|
111
113
|
|
112
114
|
We can then hit submit data from the form at `/people/new` and see that no new lines are added to the `moderate_parameters.log` file.
|
113
115
|
|
114
|
-
This means that we can remove `moderate_parameters` and move to using `permit` as
|
116
|
+
This means that we can remove `moderate_parameters` and move to using `permit` as the final migration step of `strong_parameters`:
|
115
117
|
|
116
118
|
```ruby
|
117
119
|
class PeopleController < ActionController::Base
|
@@ -129,6 +131,17 @@ class PeopleController < ActionController::Base
|
|
129
131
|
end
|
130
132
|
```
|
131
133
|
|
134
|
+
It is only _**AFTER**_ this final step of the `strong_parameters` migration has been completed that you can safely remove the `protected_attributes` line in the model:
|
135
|
+
|
136
|
+
```ruby
|
137
|
+
class Person < ActiveRecord::Base
|
138
|
+
# attr_accessible :name, :age, :height
|
139
|
+
|
140
|
+
. . .
|
141
|
+
|
142
|
+
end
|
143
|
+
```
|
144
|
+
|
132
145
|
## Contributing
|
133
146
|
|
134
147
|
Bug reports and pull requests are welcome on GitHub at https://github.com/hintmedia/moderate_parameters. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
@@ -47,6 +47,12 @@ module ModerateParameters
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
|
+
def array_of_permitted_scalars?(value)
|
51
|
+
if value.is_a?(Array) && value.all? { |element| permitted_scalar?(element) }
|
52
|
+
yield value
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
50
56
|
def non_scalar?(value)
|
51
57
|
value.is_a?(Array) || value.is_a?(Parameters)
|
52
58
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moderate_parameters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle Boe
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|