ins*_*-IT 5 postgresql ruby-on-rails
我应该在哪里以及如何定义inet?它是一种有效的postgreSQL数据类型.
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'
Run Code Online (Sandbox Code Playgroud)
迁移文件:
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
Run Code Online (Sandbox Code Playgroud)
使用支持 Postgres 增强数据类型(如 inet)的postgres_ext gem。
postgres_ext示例:将 Postgres 数据类型添加到 Rails。
postgres_ext添加了对以下 PostgresSQL 类型的迁移和 schema.rb 支持:
| 归档时间: |
|
| 查看次数: |
3001 次 |
| 最近记录: |