0

Got a issue when i run rake db:migrate. The mistake message is like

-- 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'

And i used command before migrate

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

And my migration file :

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

Could anybody tell where i made mistake please? Thank you a lot.

Ray-Von-Mice
  • 429
  • 1
  • 4
  • 16

1 Answers1

2

you are missing : before contact_id:

add_index :addresses, [:contact_id, :create_at]
darkfilo
  • 84
  • 4