This comes up a lot, so I’m providing this handy list of Rails 4 ActiveRecord Migration DataTypes here for reference.
These can be used across all database types.
:binary - is for storing data such as images, audio, or movies.
:boolean - is for storing true or false values.
:date - store only the date.
:datetime - store the date and time into a column. (What's the difference between datetime and timestamp?)
:decimal - is for decimals. (Example of how to use decimals)
:float - is for decimals. (What's the difference between decimal and float?)
:integer - is for whole numbers.
:primary_key - unique key that can uniquely identify each row in a table.
:references - used to create associations. But, I'm not sure this is an actual data type.
:string - is for small data types such as a title. (Should you choose string or text?)
:text - is for longer pieces of textual data, such as a paragraph of information. (Should you choose string or text?)
:time - is for time only.
:timestamp - for storing date and time into a column. (What's the difference between datetime and timestamp?)
If you happen to be using a PostgreSQL database, then you have access to these as well:
:hstore - storing key/value pairs within a single value. (Learn more about this new data type)
:array - an arrangement of numbers or strings in a particular row. (Learn more about it and see examples)
:cidr_address - used for IPv4 or IPv6 host addresses.
:ip_address - used for IPv4 or IPv6 host addresses, same as cidr_address but it also accepts values with nonzero bits to the right of the netmask.
:mac_address - used for MAC host addresses.
Please note, that they will be stored as strings if you use those with a non-PostgreSQL database.