jeudi 16 novembre 2017

ActiveRecord::SerializationTypeMismatch: attribute was supposed to be a Hash, but was a String

To get a hash I have this:

serialize :colors, Hash

But I have an error where it the result of this attribute looks like this:

To show this I took out the "Hash" from "serialize :colors, Hash" to see the error in the console.

"--- !map:ActiveSupport::HashWithIndifferentAccess \none: \"#87466d\"\ntwo: \"#307065\"\nthree: \"#c04992\"\nfour: \"#ffffff\"\nfive: \"#636467\"\n"

Not sure what's happened but seems like the Hash has become a string and I don't' know why. I didn't used to have this problem but I now have two versions of this project where the first is in rails 2 and the other is in rails 3 and I switch between the two. I feel like the error has occurred since going to rails 3 and coming back into rails 2. Anyone know how I can fix this error and why it has occurred?

I looked at a similar post and it hasn't helped me: "Attribute was supposed to be a Hash, but was a String"

Aucun commentaire:

Enregistrer un commentaire