Nicolas Raoul Nicolas Raoul - 4 years ago 196
Ruby Question

Rails 4 datatypes?

Where can I find a list of data types that can be used in Ruby on Rails 4 (such as text, string, integer, float, date, etc)?

I keep learning about new ones but I'd love to have a list I could easily refer to.

Answer Source

Here are all the Rails 4 (ActiveRecord migration) datatypes:

  • :binary
  • :boolean
  • :date
  • :datetime
  • :decimal
  • :float
  • :integer
  • :primary_key
  • :references
  • :string
  • :text
  • :time
  • :timestamp

These are the same as with Rails 3.

If you use PostgreSQL, you can also take advantage of these:

  • :hstore
  • :json
  • :array
  • :cidr_address
  • :ip_address
  • :mac_address

They are stored as strings if you run your app with a not-PostgreSQL database.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download