Last Updated: February 25, 2016
·
1.27K
· billagee

Accessing ActiveRecord DB column options

Sometimes it's useful to be able to access an ActiveRecord column in order to check the column options.

For example, you might want to look up the length of a column, given the column name.

The columns_hash method allows you to access a column by name, then access its options:

>> MyTable.columns_hash['name'].limit
=> 40