我想在Rails的开发环境下用上factory_girl,以便快捷地创建数据库记录。不过,这个时候sequece就不能好好地运作了。例如:
FactoryGirl.define do
factory :user do
name 'XiaoMing'
email
end
sequence :email do |n|
"#{n}@example.com"
end
end
比如说这个,我首先打开rails console,然后调用FactoryGirl.create(:user)
,正确没错;我重新打开rails console,又调用FactoryGirl.create(:user)
,出现Error,因为email重复了(都是“0@exmaple.com”)。如何有效地解决这个问题?