Here is how I use array in a rails 5 model in migration
t.text :diagnoses, array: true, default: []
in model
class Patient < ApplicationRecord
serialize :diagnoses, Array
end
in my seed method I am doing it like
patient = Patient.create(first_name: 'John', last_name: 'Smith', admission: a)
patient.diagnoses = [1, 2]
patient.save!
It give an error as
ActiveRecord::SerializationTypeMismatch: can't dump `diagnoses`: was supposed to be a Array, but was a Integer. -- 0
Thanks for any help!
patient.diagnoses = [1, 2].to_yaml.[1, 2].to_yamlsame error