我正在尝试创建一个create_posts迁移。
但是我收到了这个错误。
== 20140528222521 CreatePosts: migrating ======================================
-- create_table(:posts)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
SQLite3::SQLException: table posts has no column named description: CREATE INDEX "index_posts_on_description" ON "posts" ("description")/Users/Hyunsoo/.rvm/gems/ruby-2.1.1/gems/sqlite3-1.3.9/lib/sqlite3/database.rb:91:in `initialize'
有人知道如何解决这个问题吗?感谢。
答案 0 :(得分:0)
看起来你忘了在description
的迁移中添加CreatePosts
字段但是你在正在导致错误的那个不存在的字段上添加索引。
您需要做的是在迁移中添加description
字段,如下所示:
class CreatePosts < ActiveRecord::Migration
def change
create_table :posts do |t|
### ...
t.string :description ## <== Add this
### ...
end
end
end