← スキル一覧に戻る

user-management
by rbarazi
⭐ 0🍴 0📅 2026年1月13日
SKILL.md
name: user-management description: Implement user CRUD operations within an account with permission controls and feature flags. Use when building team member management, user administration, or account user settings in multi-tenant Rails applications.
User Management Pattern
Implement team member management within a multi-tenant Rails application with feature flags and permission controls.
When to Use
- Adding team member management
- Implementing user administration within accounts
- Building "invite user" or "add team member" functionality
- Adding permission controls for user management
Architecture Overview
Account (has_many :users)
└── Feature Flag: allow_user_management
└── Settings::UsersController
├── index (list team members)
├── new/create (add member)
└── destroy (remove member, not self)
Quick Start
1. Add Feature Flag
# Migration
add_column :accounts, :allow_user_management, :boolean, default: false, null: false
2. Create Controller
# app/controllers/settings/users_controller.rb
module Settings
class UsersController < ApplicationController
before_action :ensure_user_management_enabled
before_action :set_user, only: [:destroy]
def index
@users = Current.account.users.order(:email_address)
end
def new
@user = Current.account.users.new
end
def create
@user = Current.account.users.new(user_params)
if @user.save
redirect_to settings_users_path, notice: t("settings.users.flash.create.success")
else
render :new, status: :unprocessable_content
end
end
def destroy
if @user == Current.user
redirect_to settings_users_path, alert: t("settings.users.flash.destroy.self_delete_error")
return
end
@user.destroy
redirect_to settings_users_path, notice: t("settings.users.flash.destroy.success")
end
private
def set_user
@user = Current.account.users.find(params[:id])
end
def user_params
params.require(:user).permit(:email_address, :password)
end
def ensure_user_management_enabled
return if Current.account.allow_user_management?
redirect_to settings_path, alert: t("settings.users.flash.disabled")
end
end
end
3. Add Routes
namespace :settings do
resources :users, only: [:index, :new, :create, :destroy]
end
Security Checklist
- Always scope to
Current.account.users - Prevent self-deletion (
@user == Current.user) - Feature flag disabled by default
- Password requirements enforced (min 8 chars)
- Use
:unprocessable_contentstatus for errors
Reference Files
For complete implementation details:
- controllers.md - Full controller with all actions
- views.md - Index, form, and account settings views
- i18n.md - All translation keys
- testing.md - Controller and system specs
- permissions.md - Role-based access, invitation system
スコア
総合スコア
50/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です