问题
I am having an issue with strong params, passing an array in Devise Token Auth gem LINK
# ERROR
Unpermitted parameters: options
Configure Permitted Params
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) << [:username, options: []]
end
# also added in User.rb file
attr_accessor :options
I have tried many options, but its not allowing me to pass a data in array.
Is there any solutions ?
Thank You!
回答1:
Here is the example that will help you to setup the parameters:
# You can put the params you want to permit in the empty array.
def configure_sign_up_params
devise_parameter_sanitizer.for(:sign_up).push(:first_name, :last_name, :arr_options)
end
In your model:
class User
attr_accessor :arr_options
def initialize
self.arr_options = []
end
end
来源:https://stackoverflow.com/questions/36635111/allowing-to-pass-an-array-in-devisetokenauth-strong-params