Sha256: 56fb8691ea9a4649ec6d3a8bde626a2fafcaaee387a386f657c6a1d2e9b0e76b
Contents?: true
Size: 1.16 KB
Versions: 1
Compression:
Stored size: 1.16 KB
Contents
class SeedDump module Environment def dump_using_environment(env = {}) Rails.application.eager_load! models_env = env['MODEL'] || env['MODELS'] models = if models_env models_env.split(',') .collect {|x| x.strip.underscore.singularize.camelize.constantize } else ActiveRecord::Base.descendants end models = models.select do |model| (model.to_s != 'ActiveRecord::SchemaMigration') && \ model.table_exists? && \ model.exists? end append = (env['APPEND'] == 'true') models.each do |model| model = model.limit(env['LIMIT'].to_i) if env['LIMIT'] SeedDump.dump(model, append: append, batch_size: (env['BATCH_SIZE'] ? env['BATCH_SIZE'].to_i : nil), exclude: (env['EXCLUDE'] ? env['EXCLUDE'].split(',').map {|e| e.strip.to_sym} : nil), file: (env['FILE'] || 'db/seeds.rb'), import: (env['IMPORT'] == 'true')) append = true end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
seed_dump-3.2.2 | lib/seed_dump/environment.rb |