Sha256: b43104456c58dce1b8fbb5e4dec0a8026aca62e586ad6026dc2e9a3485e7f642
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 KB
Contents
puts "Loading ThecoreAuthCommons seeds" email = ENV["ADMIN_EMAIL"].presence || "admin@example.com" psswd = ENV["ADMIN_PASSWORD"].presence || "changeme" unless User.where(admin: true).exists? u = User.find_or_initialize_by(email: email) u.username = "Administrator" if u.respond_to? :username= u.password = u.password_confirmation = psswd u.encrypted_access_token = User.new(:password => SecureRandom.uuid).encrypted_password u.admin = true u.save(validate: false) end @values = { predicates: %i[can cannot], actions: %i[manage create read update destroy], targets: ApplicationRecord.subclasses.map {|d| d.to_s.underscore}.to_a.unshift(:all) } def fill table model = table.to_s.classify.constantize model.reset_column_information model.upsert_all @values[table].map { |p| {name: p, created_at: Time.now, updated_at: Time.now} }, unique_by: [:name] end fill :predicates fill :actions fill :targets ThecoreSettings::Setting.create(ns: :devise, key: :registerable, raw: "disable") ThecoreSettings::Setting.create(ns: :devise, key: :recoverable, raw: "disable")
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
thecore_auth_commons-3.0.6 | db/seeds.rb |
thecore_auth_commons-3.0.5 | db/seeds.rb |