Skip to content

[enhancement] tenant_level_security:install command#23

Open
mkmn wants to merge 2 commits intokufu:masterfrom
mkmn:install_generator
Open

[enhancement] tenant_level_security:install command#23
mkmn wants to merge 2 commits intokufu:masterfrom
mkmn:install_generator

Conversation

@mkmn
Copy link

@mkmn mkmn commented Jul 23, 2024

Motivation

When using this gem, you must first register TenantLevelSecurity.current_tenante_id.
I want to make this step easy.

Changes

Create InstallGenerator.
This Generator copies initializer file.

Usage

rails g tenant_level_security:install

# Motivation
When using this gem, you must first register `TenantLevelSecurity.current_tenante_id`.
I want to make this step easy.

# Changes
Create InstallGenerator.
This Generator copies initializer file.

# Usage
```
rails g tenant_level_security:install
```
@@ -0,0 +1,11 @@
module TenantLevelSecurity
module Generators
class InstallGenerator < ::Rails::Generators::Base
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gem does not have an explicit dependency on Rails, so this reference is not always safe.
It might be better to make it work only if Rails is defined.

Strictly speaking, the classes and methods available will likely change depending on the version, so some version constraints may be necessary.

@@ -0,0 +1,6 @@
# Pass current tenant ID to `TenantLevelSecurity.current_tenant_id` block
# using ActiveSupport::CurrentAttributes, RequestStore, etc...
# TenantLevelSecurity.current_tenant_id { RequestStore.store[:current_tenant_id] }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this day and age, it may be better to recommend CurrentAttributes as the default.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comment 1a06ee6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants