I’m always looking for those somewhere on web when I need them. Now I’m posting them here so I will always have them handy. If you need them then you can use this as a reference. Below is a list of supported types with its MySQL representation.
- :primary_key – int(11) DEFAULT NULL auto_increment PRIMARY KEY
- :string – varchar(255)
- :text – text
- :integer – int limit 4
- :float – float
- :decimal – decimal
- :datetime – datetime
- :timestamp – datetime
- :time – time
- :date – date
- :binary – blob
- :boolean – tinyint(1)
It can also be found in this constant in ActiveRecord ConnectionAdapters MysqlAdapter
I think that all the other type mappings could be found in appropriate ActiveRecord Connection adapters.
One thought on “Types supported by Rails Active Record”
3rd time I’m visiting your site. Exactly like you, I always forget those values. Thanks for putting that memo online !