Rails setting a maximum length on a string -


the first time i've set string length maximum in rails.

it looks can add workorder model:

validates_length_of :description, :maximum => 100 

and can create migration this:

change_column :workorders, :description, :string,  :limit => 100 

do need both?

you should include in migration, because defines actual structure of database. constrain maximum storage size limit of column (past point, see http://dev.mysql.com/doc/refman/5.0/en/char.html more details). additionally, it's possible more rails app touch database.

including in validation practice robustness, though not strictly required.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -