03_roles.rb 388 B

1234567891011
  1. # frozen_string_literal: true
  2. # Pre-create base role
  3. UserRole.everyone
  4. # Create default roles defined in config file
  5. default_roles = YAML.load_file(Rails.root.join('config', 'roles.yml'))
  6. default_roles.each_value do |config|
  7. UserRole.create_with(position: config['position'], permissions_as_keys: config['permissions'], highlighted: true).find_or_create_by(name: config['name'])
  8. end