query the :limit => value back out of the schema

Railsters:

My evil colleagues could migrate the :limit=> on an important string at any time. (Think Twitter's infamous string :limit => 140.)

I don't want to guess that limit and hard-code it into the program; I want to read it back out of the ActiveRecord field properties. How to navigate to them?

Let's say you have a model Foo, and you want the length of a column
"bar" - then this will do what you want:

Foo.columns.find { |c| c.name == 'bar' }.limit

--Matt Jones

Matt Jones wrote:

Foo.columns.find { |c| c.name == 'bar' }.limit

Tx it worked! And you can even set a "constant" on it...