我想使用PostgreSQL中的点类型。我已经完成了:
rails g model Test point:point
由此产生的迁移是:
class CreateTests < ActiveRecord::Migration
def change
create_table :tests do |t|
t.point :point
t.timestamps
end
end
end
当我运行时:
rake db:migrate
结果如下:
== CreateTests: migrating ====================================================
-- create_table(:tests)
rake aborted!
An error has occurred, this and all later migrations canceled:
undefined method `point' for #<ActiveRecord::ConnectionAdapters::PostgreSQLAdapter::TableDefinition:0x000000038991a0>/home/i/Dropbox/programming/ruby/rails_pg_for_tests/db/migrate/20140306151700_create_tests.rb:4:in `block in change'
/home/i/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/schema_statements.rb:184:in `create_table'
/home/i/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-4.0.2/lib/active_record/migration.rb:625:in `block in method_missing'
/home/i/.rvm/gems/ruby-1.9.3-p448/gems/activerecord-4.0.2/lib/active_record/migration.rb:597:in `block in say_with_time'
...
也许我需要安装PostGIS,但是如果我在PostgreSQL中已经有点类型,我不明白为什么需要它。我只需要存储纬度和经度,没有其他选项。
我应该如何使用这个点类型或者在这种情况下使用什么更好呢?
谢谢。
point
类型来自于 PostgreSQL,与 PostGIS 的geometry
类型无关。 - Mike T