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
I'm attempting was attempting to define a re-usable params type and make use of it for a request. The result is I get this: NameError (uninitialized constant Grape::Validations::Types::SymbolCoercer).
Here is my re-usable param structure:
helpers do
params :identifier_type do
optional :id, type: String
optional :name, type: String
exactly_one_of :id, :name
end
end
Since there was no clear examples in the docs of how to go about it, I was trying things like this - which just gave me errors.
params do
required :identifier, type: :identifier_type
end
post '' do
...
end
Eventually, I found a pattern that works:
params do
required :identifier, type: Hash do
use :identifier_type
end
end
post '' do
...
end
Adding something like this to the documentation would be helpful for others, I think
The text was updated successfully, but these errors were encountered:
We could probably improve the error here. It is trying to coerce a symbol and you get a SymbolCoercer error.
While type: :identifier_type seems nice, maybe it's too nice and we should not allow to say type: <something that's not actually a type>. If you think it's a great idea, maybe try to PR it? Implementing a SymbolCoercer would do it, but I think it won't be that easy ;)
I'm attempting was attempting to define a re-usable params type and make use of it for a request. The result is I get this:
NameError (uninitialized constant Grape::Validations::Types::SymbolCoercer)
.Here is my re-usable param structure:
Since there was no clear examples in the docs of how to go about it, I was trying things like this - which just gave me errors.
Eventually, I found a pattern that works:
Adding something like this to the documentation would be helpful for others, I think
The text was updated successfully, but these errors were encountered: