Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rake is aborting because undefined method `inet'

Where and how should I define inet? It's a valid postgreSQL data type.

http://www.postgresql.org/docs/8.4/static/datatype-net-types.html

rake db:migrate
==  CreateSysHosts: migrating =================================================
-- create_table(:sys_hosts)
rake aborted!
An error has occurred, this and all later migrations canceled:

undefined method `inet' for #<ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::TableDefinition:0x00000005e3e068>/opt/csdashboard/db/migrate/20140628123004_create_sys_hosts.rb:4:in `block in change'

Migration file:

class CreateSysHosts < ActiveRecord::Migration
  def change
    create_table :sys_hosts do |t|
      t.inet :address
      t.string :name
      t.string :os_name
      t.string :os_flavor
      t.int :user_id
      t.string :info
      t.string :comments

      t.timestamps
    end
  end
end
like image 643
insecure-IT Avatar asked Nov 01 '22 21:11

insecure-IT


1 Answers

Use postgres_ext gem that supports enhanced datatypes of Postgres like inet.

An example postgres_ext: Adding Postgres data types to Rails.

postgres_ext adds migration and schema.rb support for the following PostgresSQL type:

  • INET
  • CIDR
  • MACADDR
  • UUID
  • Arrays
like image 70
Lenin Raj Rajasekaran Avatar answered Nov 15 '22 07:11

Lenin Raj Rajasekaran