0

我正在尝试使用ActiveUUIDgem 使我的Survey表的主键成为 UUID。(MySQL)

即使我有:primary_key => true它仍然MUL出于某种原因将其设置为?这是预期的吗?

移民:

class CreateSurveys < ActiveRecord::Migration
  def change
    create_table :surveys, :id => false do |t|
      t.references :employee, :null => false

      t.uuid :id, :primary_key => true
      t.datetime :expired_at

      t.timestamps
    end
    add_index :surveys, :id
  end
end

模型:survey.rb

class Survey < ActiveRecord::Base

  include ActiveUUID::UUID

  belongs_to :employee

  validates :employee, :presence => true  

end
4

1 回答 1

0

我找到了答案。我需要删除add_index :surveys, :id. 显然主键已经被索引。那解决了它

于 2013-03-13T05:48:16.813 回答