0

运行 rake db:migrate 时出现问题。错误信息就像

-- create_table(:addresses)
   -> 0.1792s
-- contact_id()
rake aborted!
An error has occurred, this and all later migrations canceled:

undefined local variable or method `contact_id' for #<CreateAddresses:0x00000001724718>/var/lib/gems/1.9.1/gems/activerecord-3.2.8/lib/active_record/migration.rb:465:in `block in method_missing'

我在迁移之前使用了命令

rails g model address street:string city:string region:string postalcode:string country:string contact_id:integer

还有我的迁移文件:

class CreateAddresses < ActiveRecord::Migration
  def change
    create_table :addresses do |t|
      t.string :street
      t.string :city
      t.string :region
      t.string :postalcode
      t.string :country
      t.integer :contact_id

      t.timestamps
    end
    add_index :addresses, [contact_id, :create_at]
  end
end

谁能告诉我哪里出错了?十分感谢。

4

1 回答 1

2

:之前失踪了contact_id

add_index :addresses, [:contact_id, :create_at]
于 2013-04-12T19:24:20.200 回答