03_roles.rb 354 B

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