1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
lpr-partynest/db/seeds.rb

33 lines
1 KiB
Ruby

# frozen_string_literal: true
require 'csv'
federal_subjects_filename = Rails.root.join 'config', 'federal_subjects.csv'
CSV.foreach federal_subjects_filename,
col_sep: '|' do |(id, english_name, native_name, number, timezone)|
id = Integer(id.strip)
english_name.strip!
native_name.strip!
number = Integer(number.strip.sub(/\A0*/, ''))
timezone.strip!
FederalSubject.where(id: id).first_or_create! do |new_federal_subject|
new_federal_subject.english_name = english_name
new_federal_subject.native_name = native_name
new_federal_subject.number = number
new_federal_subject.timezone = timezone
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]
new_user.confirmed_at = Time.zone.now
new_user.account = Account.create!(
nickname: config[:nickname],
public_name: config[:public_name],
biography: config[:biography],
)
end.account.add_role :superuser
end