Last Updated: February 25, 2016
·
1.896K
· artchang

Columns for serialized attributes in Rails models need to be type :text

If you used a serialized column in your model, that column must be of type :text rather than :string

2 Responses
Add your response

Any Specific and Important reason behind this ?

over 1 year ago ·

@rshetty
When rails serializes the object for you into a string (via yaml), the chances that the string exceeds the character limit of a :string type column is very high. That is why you need :text. If you serialize an object that doesn't ever exceed the :string boundaries, you probably don't need to serialize it in the first place.

If you mean important reasons for serializing, that's really just up to application logic. It's not really needed that much, and usually you can split it up into a table instead, but I had a very specific need for it.

Hope that helps!

over 1 year ago ·