Class: CurrentScope::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#copy_initializerObject



6
7
8
# File 'lib/generators/current_scope/install/install_generator.rb', line 6

def copy_initializer
  template "initializer.rb", "config/initializers/current_scope.rb"
end

#mount_engineObject



10
11
12
# File 'lib/generators/current_scope/install/install_generator.rb', line 10

def mount_engine
  route 'mount CurrentScope::Engine => "/current_scope"'
end

#show_next_stepsObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/generators/current_scope/install/install_generator.rb', line 14

def show_next_steps
  say <<~NEXT

    CurrentScope installed. Next steps:

      1. bin/rails current_scope:install:migrations && bin/rails db:migrate
      2. Include the concerns in ApplicationController (Context first):
           include CurrentScope::Context
           include CurrentScope::Guard
      3. Seed the baseline roles and give yourself full access, e.g. in db/seeds.rb:
           CurrentScope.seed_defaults!
           CurrentScope::RoleAssignment.create!(
             subject: User.first, role: CurrentScope::Role.find_by!(name: "Owner"))
      4. Manage roles at /current_scope (full-access subjects only).

  NEXT
end