1
0
Fork 0

Import contact networks

This commit is contained in:
Alex Kotov 2019-08-05 02:11:44 +05:00
parent ac42930306
commit 29a1c6355d
Signed by: kotovalexarian
GPG Key ID: 553C0EBBEB5D5F08
1 changed files with 15 additions and 0 deletions

View File

@ -3,6 +3,7 @@
require 'csv'
federal_subjects_filename = Rails.root.join 'config', 'federal_subjects.csv'
contact_networks_filename = Rails.root.join 'config', 'contact_networks.csv'
CSV.foreach(
federal_subjects_filename,
@ -24,6 +25,20 @@ CSV.foreach(
end
end
CSV.foreach(
contact_networks_filename,
col_sep: '|',
) do |(id, nickname, public_name)|
id = Integer(id.strip)
nickname.strip!
public_name.strip!
ContactNetwork.where(id: id).first_or_create! do |new_contact_network|
new_contact_network.nickname = nickname
new_contact_network.public_name = public_name
end
end
Rails.application.settings(:superuser).tap do |config|
User.where(email: config[:email]).first_or_create! do |new_user|
new_user.password = config[:password]