Class: CurrentScope::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- CurrentScope::Generators::InstallGenerator
- Defined in:
- lib/generators/current_scope/install/install_generator.rb
Constant Summary collapse
- GUIDE_PATH =
An ABSOLUTE URL, not a repo-relative path. This prints in the HOST's terminal, in the HOST's app directory: "docs/guides/..." would resolve against their app, where it does not exist — and the gemspec ships only app,config,db,lib + README, so it is not in the installed gem either. Shipping docs/ wouldn't fix it (nobody reads docs out of a gem's install dir); a URL is the only form that resolves from where the reader is standing, and terminals make it clickable. (#64 review, qodo)
Points at blob/main deliberately: the guide does not exist at the last release tag (it landed after v0.2.0), so a version-pinned URL would 404 today. Revisit pinning to "blob/v#VERSION" at the next release, when a tag containing the guide exists. (#71 review, qodo)
"docs/guides/adopting-in-an-existing-app.md".freeze
- GUIDE_URL =
"https://github.com/davidteren/current_scope/blob/main/#{GUIDE_PATH}".freeze
Instance Method Summary collapse
Instance Method Details
#copy_initializer ⇒ Object
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_engine ⇒ Object
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_steps ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# 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 say_retrofit_warning if existing_app? end |