Interesting idea. If what you're after is consistent data, why are you randomizing anything?
On Wed, Feb 17, 2016 at 9:48 AM, Ben Colon <ben.co...@gmail.com> wrote: > 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 rubyonrails-core+unsubscr...@googlegroups.com. > To post to this group, send email to rubyonrails-core@googlegroups.com. > Visit this group at https://groups.google.com/group/rubyonrails-core. > For more options, visit https://groups.google.com/d/optout. > -- 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 rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at https://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.