Sha256: 4809c6e397c63c07ab424716ea456e9c06f161104d60a08876d10a603c8c6d66
Contents?: true
Size: 1.25 KB
Versions: 7
Compression:
Stored size: 1.25 KB
Contents
require 'faker' require 'factory_girl_rails' include FactoryGirl::Syntax::Methods # This file should contain all the record creation needed to seed the database # with its default values. The data can then be loaded with the rake db:seed # (or created alongside the db with db:setup). # # For the seeded attribute values, see factories.rb puts puts 'Seeding the database...' puts dev_tables_to_seed = %w( <%= config[:using_devise] ? 'admin_user' : 'factory_name' %> ) production_tables_to_seed = %w( <%= config[:using_devise] ? 'admin_user' : 'factory_name' %> ) test_tables_to_seed = %w() if ENV['TABLES'].present? # Allow overriding which tables we seed if the TABLES env var is present tables = ENV['TABLES'].to_s.split(',') else # Load the tables specified based on the environment tables = case Rails.env when 'production' production_tables_to_seed when 'staging', 'development' dev_tables_to_seed when 'test' test_tables_to_seed else message = 'Error: Rails environment not found. Please check seeds.rb.' fail StandardError.new, message: message end end # raise StandardError.new, message: 'No Tables Specified' if tables.blank? tables.each do |table_name| eval("Seeder.#{table_name}") end
Version data entries
7 entries across 7 versions & 1 rubygems