Varchar attribute with migration

I can’t seem to find this anywhere… How would I define the number in
varchar(#) with the migration tool. By default when using :string it
sets it at 255. Probably a really simple answer to this, thanks for
the help.

:limit => n

On 08/09/06, salo [email protected] wrote:

I can’t seem to find this anywhere… How would I define the number in
varchar(#) with the migration tool. By default when using :string it
sets it at 255. Probably a really simple answer to this, thanks for
the help.


Rasputin :: Jack of All Trades - Master of Nuns
http://number9.hellooperator.net/

Take a look at :limit.

add_column :your_table, :your_column, :string, :limit => 20

This page from the Rails API lists all the options.

Aaron

I can’t seem to find this anywhere… How would I define the number in
varchar(#) with the migration tool. By default when using :string it
sets it at 255. Probably a really simple answer to this, thanks for
the help.

There’s a reason that it defaults to 255. Because for the vast majority
of cases, it Just Doesn’t Matter. It’s not worth dedicating brain
cycles to try to figure out what the optimal size of a field is.
Especially not with varchar, which automatically contracts and expands
any way. You’ll usually guess too low anyway and then later have to
change it.

David Heinemeier H.

thanks for the help and advice…

-salo