Hey there,

In many projects, I guess like everyone, we're using the seed file to 
generate a bunch of models with random data.
Obviously, after running db:seed task, each developer has a "different" 
database. Not cool.
If we need to sync those data, we prefix seed.rb code with something like 

```
generator = Rand.new(1234567890)
```
and replace all "rand" calls by "generator.rand"

As we do that in many projects, I could write a gem which would override 
the Railties `load_seed` method and insert a fixed `srand` call before 
seed.rb load, so all `rand` calls during seed will be "predictable".

But is it make sense to make a Railties pull request with this (with a 
config options to enable/disable "predictable" seed) ?
Something like :

```
def load_seed
  srand(config.predictable_seed) if config.predictable_seed
  seed_file = paths["db/seeds.rb"].existent.first
  load(seed_file) if seed_file
ensure
  srand if config.predictable_seed
end
```

Thoughts ?
Thank you
Ben

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to