You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*[#1568](https://github.com/ruby-grape/grape/pull/1568): Add `proc` option to `values` validator to allow custom checks - [@jlfaber](https://github.com/jlfaber).
8
8
*[#1575](https://github.com/ruby-grape/grape/pull/1575): Include nil values for missing nested params in declared - [@thogg4](https://github.com/thogg4).
Copy file name to clipboardExpand all lines: README.md
+12-2
Original file line number
Diff line number
Diff line change
@@ -501,9 +501,19 @@ Route string parameters will have precedence.
501
501
502
502
By default parameters are available as `ActiveSupport::HashWithIndifferentAccess`. This can be changed to, for example, Ruby `Hash` or `Hashie::Mash` for the entire API.
Copy file name to clipboardExpand all lines: UPGRADING.md
+27-3
Original file line number
Diff line number
Diff line change
@@ -5,9 +5,33 @@ Upgrading Grape
5
5
6
6
#### Changes in Parameter Class
7
7
8
-
The default class for `params` has changed from `Hashie::Mash` to `ActiveSupport::HashWithIndifferentAccess` and the `hashie` dependency has been removed. To restore the behavior of prior versions, add `hashie` to your `Gemfile` and use `TODO`.
8
+
The default class for `params` has changed from `Hashie::Mash` to `ActiveSupport::HashWithIndifferentAccess` and the `hashie` dependency has been removed. This means that by default you can no longer access parameters by method name.
9
9
10
-
[TODO]
10
+
```
11
+
class API < Grape::API
12
+
params do
13
+
optional :color, type: String
14
+
end
15
+
get do
16
+
params[:color] # use params[:color] instead of params.color
17
+
end
18
+
end
19
+
```
20
+
21
+
To restore the behavior of prior versions, add `hashie` to your `Gemfile` and `include Grape::Extensions::Hashie::Mash::ParamBuilder` in your API.
22
+
23
+
```
24
+
class API < Grape::API
25
+
include Grape::Extensions::Hashie::Mash::ParamBuilder
26
+
27
+
params do
28
+
optional :color, type: String
29
+
end
30
+
get do
31
+
# params.color works
32
+
end
33
+
end
34
+
```
11
35
12
36
This behavior can also be overridden on individual parameter blocks using `build_with`.
13
37
@@ -26,7 +50,7 @@ def request
26
50
end
27
51
```
28
52
29
-
See [#1594](https://github.com/ruby-grape/grape/pull/1594) for more information.
53
+
See [#1610](https://github.com/ruby-grape/grape/pull/1610) for more information.
0 commit comments