Process seed "relation_statuses"
This commit is contained in:
parent
e2cb353141
commit
f6d5bd981b
1 changed files with 13 additions and 2 deletions
15
db/seeds.rb
15
db/seeds.rb
|
@ -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]
|
||||||
|
|
Reference in a new issue