Sha256: ba0be060ba6a14968fbc5209c9171392779ba94a36c6e725db7afee8ea76346c
Contents?: true
Size: 1.11 KB
Versions: 3
Compression:
Stored size: 1.11 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" u.password = u.password_confirmation = psswd u.admin = true u.save(validate: false) end # If there are previous users without the access_token, create it: User.all.each do |u| if u.access_token.blank? begin u.access_token = SecureRandom.uuid #urlsafe_base64(32) end while ::User.exists?(access_token: u.access_token) u.save(validate: false) end 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
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
thecore_auth_commons-2.4.0 | db/seeds.rb |
thecore_auth_commons-2.3.9 | db/seeds.rb |
thecore_auth_commons-2.3.8 | db/seeds.rb |