How can i disable the auto-increment for a primary key data type. The
purpose of using primary_key data type is using different name for
primary key. But we still want to use all the properties of "id"
except for auto increment part.
I had my migration as following
#=============MIGRATION
def self.up
create_table :pk2s , :id=> false do |t|
t.primary_key :uid
t.string :name
t.timestamps
end
end
# ========== Model
class Pk2 < ActiveRecord::Base
set_primary_key "uid"
end
--vipin
Vipin wrote:> How can i disable the auto-increment for a primary key data type. The > purpose of using primary_key data type is using different name for > primary key. But we still want to use all the properties of "id" > except for auto increment part.Given that it looks to me like you want to implement uuid fields in your application maybe this will help: http://codesnipers.com/?q=node/143&title=Using-UUID/GUID-as-Primary-Key-in-Rails -- Posted via http://www.ruby-forum.com/.