2014-06-28 20 views
5

Dove e come dovrei definire inet? È un tipo di dati postgreSQL valido.Il rastrello si interrompe a causa del metodo non definito `inet '

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' 

file di migrazione:

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 
+0

si può pubblicare il file di migrazione? – Pavan

+0

ha aggiornato la domanda con il file di migrazione. –

risposta

2

Usa postgres_ext gemma che supporta avanzate tipi di dati di Postgres come inet.

Un esempio postgres_ext: Adding Postgres data types to Rails.

postgres_ext aggiunge il supporto della migrazione e schema.rb per il seguente tipo di PostgreSQL:

  • INET
  • CIDR
  • MACADDR
  • UUID
  • Array
+0

Ciò richiederà un aggiornamento da 3.2.14 a 4.x giusto? –

+0

Credo di si. Oppure prova una versione precedente - https://rubygems.org/gems/postgres_ext/versions/1.0.0 – emaillenin

+0

Ora ottengo il metodo non definito 'int 'per # /opt /csdashboard/db/migrate/20140628123004_create_sys_hosts.rb:9:in 'blocco in cambio' –

Problemi correlati