"NoMethodError: undefined method `type' for "character varying":String" after "rake db:migrate"
"NoMethodError: undefined method `type' for "character varying":String" after "rake db:migrate"
我尝试在微博中添加签到,但抽取后出现错误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:
您遇到的问题是 point 方法在 ActiveRecord 中不存在。
为 table 实例化一个新列。类型参数通常是迁移本机类型之一,它是以下之一::primary_key, :string, :text, :integer, :float, :decimal, :datetime, :time, :date, :二进制,:布尔值。
希望对您有所帮助
假设你使用的是 gem activerecord-postgis-adapter
,你最好尝试将数据库适配器更改为 postgis
,如他们官方文档中所建议的:
我尝试在微博中添加签到,但抽取后出现错误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:
您遇到的问题是 point 方法在 ActiveRecord 中不存在。
为 table 实例化一个新列。类型参数通常是迁移本机类型之一,它是以下之一::primary_key, :string, :text, :integer, :float, :decimal, :datetime, :time, :date, :二进制,:布尔值。
希望对您有所帮助
假设你使用的是 gem activerecord-postgis-adapter
,你最好尝试将数据库适配器更改为 postgis
,如他们官方文档中所建议的: