Created
May 3, 2018 18:56
-
-
Save richmolj/0311f07c3ff135a8da1fdbb681a431f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/strong_resources.rb | |
Parameters = ActionController::Parameters | |
# first, define our custom type according to the stronger_parameters documentation | |
custom_type = Parameters.array(Parameters.id) | |
# then, register this custom type with strong resources. we need: | |
# * a name for the type (:array_of_integers) | |
# * since swagger only allows certain types, how should swagger handle this type? | |
# * the type defined above | |
strong_param :array_of_integers, swagger: :array, type: custom_type | |
strong_resource :thing do | |
# And now use it just like you would :string, :integer, etc | |
attribute :foo, :array_of_integers | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment