Difference between string and text in rails? -
I am creating a new web app using Rail, and wondering, string and
text
and when should each be used?
The difference depends on how the symbol is converted into related column type in the query language.
With MySQL: string is mapped to VARCHAR (255) -
: string | VARCHAR | : Border = & gt; 1 to 255 (default = 255): text | TINYTEXT, TEXT, MEDIUMTEXT, or LONGTEXT2. : Border = & gt; 1 to 4294967296 (default = 65536)
Reference:
Use each When should it be done?
As a general rule of thumb, use : string
for short text input (username, email, password, title, etc.) and : Text,
for more expected input such as details, comment content, etc.
Comments
Post a Comment