p = People.first
#p { :id => 1}
p.destroy
s = People.new
#s {:id => 2}
s = p.id
# s.id => 1
s.save
#real output: UPDATE peoples set updated_at ='2012.....' WHERE people.id = 2
#expect output : UPDATE peoples set updated_at ='2012.....' WHERE people.id = 2
我想在销毁一些id之后解救activerecord id。可能吗?
答案 0 :(得分:1)
是的,这是可能的。但要小心,旧的个人资料链接可能会路由到其他个人资料(id
5的老人被删除,新人将与5)
Peson.create(:id => 5)
答案 1 :(得分:0)
是的,您可以在上面的代码示例中使用它
s = p.id
应为s.id = p.id