开发者

Add_Index() Error using Rails ,PostGres and Windows xp

I'm trying to add an index to my models, but keep开发者_如何学Go getting this error.

PG:Error Error:column "user_id" does not exist :CREATE INDEX "index_users_on_user_id" ON "users" ("user_id")

class CreateUsers < ActiveRecord::Migration
  def self.up
    create_table :users do |t|
      t.references :role
      t.references :carrier
      t.string "first_name"
      t.string "last_name"
      t.string "user_name"
      t.string "hashed_password"
      t.string "user_salt"
      t.string "telephone"

      t.timestamps
    end
    add_index("users", "user_id")
    add_index("users", "role_id")
    add_index("users", "user_name")
  end

  def self.down
    drop_table :users
  end
end


You don't have anywhere the column user_id in the migration. The automagical column that rails creates for you is called 'id'.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜