Class: Planter::Generators::SeederGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Planter::Generators::SeederGenerator
- Defined in:
- lib/generators/planter/seeder_generator.rb
Overview
Rails generator that creates one or more Planter seeder files.
By default, generated seeders include a TODO comment and an empty seed
method so they do not raise until a seeding method is chosen. Pass
--seeding-method=csv, --seeding-method=data-array, or
--seeding-method=custom to generate a seeder for a specific style. The
csv method also creates a CSV seed file with headers pulled from the
table being seeded.
Constant Summary collapse
- SEEDING_METHODS =
Generator-supported seeding method templates.
%i[csv data_array custom].freeze
Instance Method Summary collapse
-
#generate_seeders ⇒ Object
Generate the requested seeder, or generate a seeder for every table when the argument is
ALL.
Instance Method Details
#generate_seeders ⇒ Object
Generate the requested seeder, or generate a seeder for every table
when the argument is ALL.
32 33 34 |
# File 'lib/generators/planter/seeder_generator.rb', line 32 def generate_seeders (seeder == "ALL") ? tables.each { |t| generate(t) } : generate(seeder) end |