1
0
Fork 0

Process seed "relation_statuses"

This commit is contained in:
Alex Kotov 2019-09-21 19:39:28 +05:00
parent e2cb353141
commit f6d5bd981b
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08

View file

@ -4,8 +4,9 @@ require 'csv'
seeds_dirname = Rails.root.join 'config', 'seeds' seeds_dirname = Rails.root.join 'config', 'seeds'
federal_subjects_filename = seeds_dirname.join 'federal_subjects.csv' federal_subjects_filename = seeds_dirname.join 'federal_subjects.csv'
contact_networks_filename = seeds_dirname.join 'contact_networks.csv' contact_networks_filename = seeds_dirname.join 'contact_networks.csv'
relation_statuses_filename = seeds_dirname.join 'relation_statuses.csv'
CSV.foreach( CSV.foreach(
federal_subjects_filename, federal_subjects_filename,
@ -38,6 +39,16 @@ CSV.foreach contact_networks_filename, col_sep: '|' do |(id, codename, name)|
end end
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| Rails.application.settings(:superuser).tap do |config|
user = User.where(email: config[:email]).first_or_create! do |new_user| user = User.where(email: config[:email]).first_or_create! do |new_user|
new_user.password = config[:password] new_user.password = config[:password]