Class: BulletTrain::Roles::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/bullet_train/roles/install/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_roles_config_fileObject



11
12
13
14
15
16
17
# File 'lib/generators/bullet_train/roles/install/install_generator.rb', line 11

def add_roles_config_file
  puts("Creating role.yml inside config/models with default roles\n")

  copy_file "roles.yml", "config/models/roles.yml"

  puts("Success 🎉🎉\n\n")
end

#configure_modelsObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/generators/bullet_train/roles/install/install_generator.rb', line 19

def configure_models
  json_data_type_identifier = find_json_data_type_identifier

  top_level_model = ask("Which model do you want to use as a top-level model that represents Membership? (Defaults to Membership)") || "Membership"

  generate_migration_to_add_role_ids(top_level_model, json_data_type_identifier)

  include_role_support_in_top_level_model(top_level_model)

  associated_model = ask("Which model/association of #{top_level_model} do you consider to be the Team? (Default to Team)") || "Team"

  # Asks for a model we can setup some default permissions for.
  # TODO: follow back Andrew on question about this in Slack

  add_permit_to_ability_model(top_level_model, associated_model)
  add_concern_to_user
end