2013-04-12 18 views
0

當我運行rake db:migrate時出現問題。該錯誤消息類似於rake 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 

有誰告訴我哪裏出錯了嗎?萬分感謝。

回答

1

你缺少:contact_id:AAA非常感謝

add_index :addresses, [:contact_id, :create_at] 
+0

,但它告訴我,現在的SQLite3 ::的SQLException:表中的地址沒有名爲create_at柱: –

+0

好的知道了created_at .... IM這樣一個血腥的傻瓜非常感謝你Darkfilo –

相關問題