Seed scripts
This commit is contained in:
parent
c2abf356f4
commit
a82e1703d8
3 changed files with 17 additions and 0 deletions
1
db/data/scripts.csv
Normal file
1
db/data/scripts.csv
Normal file
|
@ -0,0 +1 @@
|
|||
hello | Поприветствовать |
|
|
1
db/scripts/hello.rb
Normal file
1
db/scripts/hello.rb
Normal file
|
@ -0,0 +1 @@
|
|||
# frozen_string_literal: true
|
15
db/seeds.rb
15
db/seeds.rb
|
@ -79,6 +79,21 @@ do |(org_unit_kind, codename, name)|
|
|||
end
|
||||
end
|
||||
|
||||
csv_foreach :scripts \
|
||||
do |(codename, name)|
|
||||
codename.strip!
|
||||
name.strip!
|
||||
|
||||
source_code = File.read(
|
||||
File.expand_path(File.join('scripts', "#{codename}.rb"), __dir__),
|
||||
)
|
||||
|
||||
Script.where(codename: codename).first_or_create!(
|
||||
name: name,
|
||||
source_code: source_code,
|
||||
)
|
||||
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]
|
||||
|
|
Reference in a new issue