Sha256: c8b0a299c278d166a6b0f10471e63010d874e1343a27e115288a1c402014f033
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 KB
Contents
require 'pathname' require 'yaml' module Skr module Core module DB class Seed @@seeds = [] class << self def add(&block) @@seeds.push(block) end # Loads the database with seed models # Currently loads {GlAccount}, {PaymentTerm}, and {Location} def execute! seeds_path = Pathname.new(__FILE__).dirname.join('seed') unless Location.default Location.create( code: Core.config.default_location_code, name: "System default", address: Address.new(name:"System default") ) end YAML::load( seeds_path.join('chart_of_accounts.yml').read ).each do | acct_data | GlAccount.where(number: acct_data['number'].to_s).any? || GlAccount.create!(acct_data) end YAML::load( seeds_path.join('payment_terms.yml').read ).each do | acct_data | PaymentTerm.where(code: acct_data['code'].to_s).any? || PaymentTerm.create!(acct_data) end @@seeds.each(&:call) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stockor-core-0.2 | lib/skr/core/db/seed.rb |