Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 4 Rgeo、Mysql和空间索引错误_Ruby On Rails 4_Rgeo - Fatal编程技术网

Ruby on rails 4 Rgeo、Mysql和空间索引错误

Ruby on rails 4 Rgeo、Mysql和空间索引错误,ruby-on-rails-4,rgeo,Ruby On Rails 4,Rgeo,尝试运行迁移以添加空间索引时,请获取 Unknown key: spatial/Users/ME/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.2/lib/active_support/core_ext/hash/keys.rb:70:in `block in assert_valid_keys' 使用 Ruby 2.0.353 Rails 4.0.2 RGEO 0.3.20 RGEO活动记录0.4.6 列表项 activerecord-m

尝试运行迁移以添加空间索引时,请获取

Unknown key: spatial/Users/ME/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.2/lib/active_support/core_ext/hash/keys.rb:70:in `block in assert_valid_keys'
使用

  • Ruby 2.0.353
  • Rails 4.0.2
  • RGEO 0.3.20
  • RGEO活动记录0.4.6
  • 列表项
  • activerecord-mysql2space-adapter 0.4.3
迁移索引文件看起来像

class CreateAddresses < ActiveRecord::Migration
  def change
    create_table :addresses, :options => 'ENGINE=MyISAM' do |t|
      t.string :street_1
      t.string :street2
      t.string :city
      t.string :state
      t.string :zip
      t.string :country
      t.string :full_address
      t.column :latlon, :point, :null => false

      t.timestamps
    end
    add_index :addresses, :latlon, :spatial => true
  end
end
class CreateAddresses'ENGINE=MyISAM'do | t|
t、 字符串:street_1
t、 字符串:street2
t、 字符串:城市
t、 字符串:state
t、 字符串:zip
t、 字符串:国家
t、 字符串:完整地址
t、 列:latlon,:point,:null=>false
t、 时间戳
结束
添加索引:address,:latlon,:spatial=>true
结束
结束

更新


当我将database.yml文件中的适配器从mysql2更改为mysql2spatial时,更正了此错误和其他错误

我希望我能对此进行15次投票!应该明确地记录在某个地方。现在就在GitHub上制造问题。干杯更新:由我在年解决,我用postgis适配器遇到了相同的错误。无法理解为什么
spatial:true
在我的
add_index
命令中停止工作(我甚至在一些较旧的迁移中仍然使用该命令)。这并不是一个真正合适的解决方案,但在它的位置指定
使用::gist
似乎使迁移工作正常desired@HarryWood看起来
使用::gist
而不是
spatial:true
实际上是正确的解决方案-请参阅