Saturday, March 20, 2010

ActiveRecord::SerializationTypeMismatch (search_fields was supposed to be a Hash, but was a String):

This error was happening on a field that stored a serialized Hash.

It appears the size of the field was too small. I had it at a string varchar(255) and after changing it to a limit of 1000, the error went away.

change_column :users, :search_fields, :string, :limit => 1000

I presume this is due to a few characters at the end getting cut off, so the data structure no longer matched a hash.

1 comment:

  1. Didn't think this would work, but it did! Thanks.