Strong parameters
Handling with third party JSON
def logout_params
raw_parameters = params.require(:logout)
if raw_parameters.kind_of?(String)
parameters = ActionController::Parameters.new(Convertor.to_sym_json(raw_parameters))
parameters.permit(:account, :auth_token)
elsif raw_parameters.kind_of?(Hash)
params.require(:logout).permit(:account, :auth_token)
else
raise "Invalid params"
end
end
module Convertor
def self.to_sym_json(string_json)
JSON.parse(string_json, symbolize_names: true)
end
end
Reference