In a rails migration, how can you remove the limit of a field

If you previously specified a limit in a migration and want to just remove the limit, you can just do this:

change_column :users, :column, :string, :limit => 255

255 is the standard length for a string column, and rails will just wipe out the limit that you previously specified.

Updated:

While this works in a number of Rails versions, you would probably be better suited to use nil like in Giuseppe’s answer.

change_column :users, :column, :string, :limit => nil

That means the only thing you were doing wrong was using null instead of nil.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)