From f6d5bd981b5042b3269c74d2ab9d988c2d4d2641 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sat, 21 Sep 2019 19:39:28 +0500 Subject: [PATCH] Process seed "relation_statuses" --- db/seeds.rb | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 24a99fa..e566e2d 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -4,8 +4,9 @@ require 'csv' seeds_dirname = Rails.root.join 'config', 'seeds' -federal_subjects_filename = seeds_dirname.join 'federal_subjects.csv' -contact_networks_filename = seeds_dirname.join 'contact_networks.csv' +federal_subjects_filename = seeds_dirname.join 'federal_subjects.csv' +contact_networks_filename = seeds_dirname.join 'contact_networks.csv' +relation_statuses_filename = seeds_dirname.join 'relation_statuses.csv' CSV.foreach( federal_subjects_filename, @@ -38,6 +39,16 @@ CSV.foreach contact_networks_filename, col_sep: '|' do |(id, codename, name)| end end +CSV.foreach relation_statuses_filename, col_sep: '|' do |(codename, name)| + codename.strip! + name.strip! + + RelationStatus.where(codename: codename).first_or_create! \ + do |new_relation_status| + new_relation_status.name = name + end +end + Rails.application.settings(:superuser).tap do |config| user = User.where(email: config[:email]).first_or_create! do |new_user| new_user.password = config[:password]