We build Web & Mobile Applications.
A quick tip - ActiveRecord provides a number of methods that allow you to access information about the underlying table columns for a model.
columnsColumn objects.columns_hashcolumns method but returns a Hash using column names as keys and Column objects as values.column_namesThe Column objects returned by columns and columns_hash can then be used to get information such as the data type and default values, for example:
User.columns_hash['email'].type
=> :string
User.columns_hash['email'].default
=> nil
User.columns_hash['email'].sql_type
=> "varchar(255)"