Skip to content

Instantly share code, notes, and snippets.

@benoittgt
Created April 9, 2021 14:39
Show Gist options
  • Select an option

  • Save benoittgt/f3be13d8e325d49f37cdaf8a1e7a13e5 to your computer and use it in GitHub Desktop.

Select an option

Save benoittgt/f3be13d8e325d49f37cdaf8a1e7a13e5 to your computer and use it in GitHub Desktop.
# start FactoryBot id sequence at a different number. Naive approach.
# other idea https://github.com/thoughtbot/factory_bot/issues/350#issuecomment-14475441
FactoryBot.define do
factory :app do
sequence(:id) { |n| 1.to_s.ljust(self.instance.class.name.size, "0").to_i + n }
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment