[Solved] Undefined method ‘[]’ for nil:NilClass when trying to write to db in active record [closed]


I figured out the reason for

ArgumentError: uncaught throw “Error in record 314675: undefined method ‘[]’ for nil:NilClass’

was primarily from an incomplete set of input variables that is required by the def init method. Because this was an ArgumentError that was thrown from the function1 method, I was only invested in debugging function1. The original model takes in 7 input variables, including function1. I realized that couple of the input variables did not match the data type, e.g., the model takes in integers while the input variable was in string.

solved Undefined method ‘[]’ for nil:NilClass when trying to write to db in active record [closed]