Strings are usually 255 characters length but not all databases treat the string field in the same way. For instance, PostgreSQL can create string column of different sizes.
There are at least 2 very good reasons to specify the value of the string field:
- cross-database compatibility
- database performance
If you need a string column to store the country code that is 2 chr length, why you want the database to reserve additional 253 characters for... nothing?
Also note you should always validate the length of the field value in your model.
If you try to create a record with a name that exceeds your maximum length:
- SQLIte3 will silently trim the value
- MySQL will silently trim the value
- PostgreSQL will raise an exception
So, always validates_length_of
your attribute.