This week, I had a pull request accepted into Rails which adds support for PostgreSQL’s MACADDR, INET, and CIDR datatypes. In Rails 4.0, the following migration will be supported:
create_table :network_types do |t| t.cidr :cidr_address t.inet :ip_address t.macaddr :mac_address end
Also, the schema dumper supports these types as well (previously they
would appear as
string types in the schema.rb file).
ActiveRecord will also cast the values of the INET and CIDR types to Ruby’s IPAddr, while MACADDR will continue to be converted to a string.