" NoMethodError:未定义的方法`type'为"字符变化":字符串"在" rake db:migrate"

时间:2015-12-02 22:45:06

标签: ruby-on-rails ruby database ruby-on-rails-3 ruby-on-rails-4

我试图在微信上添加签到但是我在rake db:migrate之后出错了。这是什么意思?

错误

  $ rake db:migrate --trace
    ** Invoke db:migrate (first_time)
    ** Invoke environment (first_time)
    ** Execute environment
    ** Invoke db:load_config (first_time)
    ** Execute db:load_config
    ** Execute db:migrate
    rake aborted!
    NoMethodError: undefined method `type' for "character varying":String

add_checkin_to_microposts

 class AddCheckinToMicroposts < ActiveRecord::Migration
   def change
      add_column :microposts, :location, :point, :geographic => true
   end
 end

的database.yml

 development:
  adapter: postgresql
  schema_search_path: public, postgis
  encoding: unicode
  database: blog_development
  host: localhost
  pool: 5
  username: ******** 
  password: 

2 个答案:

答案 0 :(得分:2)

假设您正在使用gem // intercept all incoming routes and log it interceptFrom().process(new Processor() { @Override public void process(Exchange exchange) throws Exception { System.out.println("Triggered"); } }); ,您最好按照其官方文档中的建议尝试将数据库适配器更改为activerecord-postgis-adapter

  

https://github.com/rgeo/activerecord-postgis-adapter

答案 1 :(得分:1)

您遇到的问题是ActiveRecord中不存在 point 方法。

实例化表的新列。 type参数通常是迁移本机类型之一,它是以下之一:: primary_key,:string,:text,:integer,:float,:decimal,:datetime,:time,:date,:binary,:布尔值。

更多信息请阅读http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/TableDefinition.html#method-i-column

希望这有帮助