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
Written by Bill Agee
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#