5
如何为我的IdClient字段设置主键?我试过所有的方法,但我会得到错误(rails 3.0.9)...你能帮我吗?如何在Rails迁移中设置ruby中的主键?
class CreateCustomers < ActiveRecord::Migration
def self.up
create_table :customers do |t|
t.integer :IdCustomer
t.string :username
t.string :crypted_password
t.string :password_salt
t.string :persistence_token
t.string :email
t.string :Skype
t.string :ICQ
t.string :Firstname
t.string :Lastname
t.string :Country
t.string :State
t.string :City
t.string :Street
t.string :Building
t.integer :Room
t.string :AddressNote
t.date :DateOfReg
t.integer :CustGroup
t.float :TotalBuy
t.timestamps
add_index(:customers, :IdCustomer, :unique => true)
end
end
def self.down
drop_table :customers
end
end
另外如何在模型中设置关系?
但为什么没有?所以我不再需要我的领域idclient? – byCoder 2012-04-10 06:26:57
@ ovatsug25你看完我的回答了吗?这将包括我提到的“*非常好的理由*”。 – meagar 2013-01-25 15:22:12
ohhh,我知道...谢谢你指出技术......但我仍然不想这样做...... – ovatsug25 2013-01-25 16:27:48