Class | SeedFu::Seeder |
In: |
lib/seed-fu/seeder.rb
|
Parent: | Object |
Creates or updates seed records with data.
It is not recommended to use this class directly. Instead, use `Model.seed`, and `Model.seed_once`, where `Model` is your Active Record model.
@param [ActiveRecord::Base] model_class The model to be seeded @param [Array<Symbol>] constraints A list of attributes which identify a particular seed. If
a record with these attributes already exists then it will be updated rather than created.
@param [Array<Hash>] data Each item in this array is a hash containing attributes for a
particular record.
@param [Hash] options @option options [Boolean] :quiet (SeedFu.quiet) If true, output will be silenced @option options [Boolean] :insert_only (false) If true then existing records which match the
constraints will not be updated, even if the seed data has changed
Insert/update the records as appropriate. Validation is skipped while saving. @return [Array<ActiveRecord::Base>] The records which have been seeded