Spread is a simple way to run seed data based on the current Rails environment. Simply create a seeds/
directory under db/
and put your environment-specific seeds in there. Name each file the name of the environment followed by .rb
. To load these seeds, simply add a call to Spread.load
to your seeds.rb
file. If you have a more complex environment, use the seed
method to tell Spread to load certain seed files for certain environments. HINT: This can also be used to break your seed files out and organize them.
Using :all as an environment will cause Spread to apply the settings to all environments.
Tells Spread to load a seed file for a specific environment. Spread is smart enough not to load a seed more than once. This method takes a hash parameter and uses the keys as the seed file and the value(s) as the environment to load this seed file in.
Spread.seed :production => :testing Spread.seed :flinstones => [ :production, :development, :testing, :staging ] Spread.seed :scooby => :production, :velma => :staging
Tells Spread to load any seeds for the specified environment within other environment(s). This is a good for scenarios in which you’d like to mimick your production environment.
Spread.any :production => :staging Spread.any :production => [ :staging, :preproduction ]
Performs the actual loading of seed files setup in Spread. Add this to your seeds.rb file to invoke it.