Polymorphic association inserts 0 instead of raising error when column is misconfigured as Integer
This happens because parameters sent through with requests come through as strings, and therefore for integer columns that are set from params, rails calls to_i on the string to get the integer. If it can't resolve an integer from it (which happens if the string doesn't start with some digits) then to_i returns 0. This is just how ruby works. Sometimes rails will spot this and raise a warning, but it can't possibly know the name of every column that it has to check. Eg check this out (from console)
>> quiz = Quiz.first
=> <a quiz>
>> quiz.user_id = "foo"
=> "foo"
>> quiz.save
=> true
>> quiz.user_id
=> 0