Where is the documentation page for ActiveRecord data types?

Blankman picture Blankman · Oct 18, 2010 · Viewed 41.9k times · Source

I can't find the active record documenation page that has a list of all the data types.

Can someone help me out?

Answer

Mark Thomas picture Mark Thomas · Oct 18, 2010

If you're talking about the types for migrations, e.g. string, integer, datetime, etc, then you want ActiveRecord::ConnectionAdapters::TableDefinition, the column method. (Rails 5 edit: see also connection.add_column.)

As of this update, the standard types are:

  • :primary_key
  • :string
  • :text
  • :integer
  • :bigint
  • :float
  • :decimal
  • :numeric
  • :datetime
  • :time
  • :date
  • :binary
  • :boolean

The implementation of :decimal is different with each database, so I'd avoid it if possible. You may use a type not in this list as long as it is supported by your database (for example, :polygon in MySQL), but this will not be database agnostic and should also be avoided.