In writing a Rails app there are several places where string table column widths are needed: validations, RSpec testing, input forms, etc. It seems worthwhile to set the length limit on strings in the DB also.
At present I've set a LENGTHS hash in the model so I can access the lengths in other places and keep the code DRY in this respect. If I set the length limits in the DB, is it possible to read the values from there (or initialize the LENGTHS hash with them) to make the code even more DRY? That is, what is the code to read a string length limit of a database column in the model so I can use it?