Generators
Catalyst ships Rails generators that create the migrations, initializers and boilerplate each feature needs. Run rails generate catalyst:install first, then add feature generators as you need them.
Quick Referenceβ
| Command | Description |
|---|---|
rails generate catalyst:install | Initial setup - creates migrations, initializer, and mounts the engine |
rails generate catalyst:install_role | Sets up role-based access control with permissions |
rails generate catalyst:install_user_groups | Creates User Groups tables and seeds the Enable User Groups setting |
rails generate catalyst:add_authentication | Adds Devise authentication if no auth system exists |
rails generate catalyst:add_graphql | Installs GraphQL API with types, mutations, and queries |
rails generate catalyst:add_scheduler | Creates cron job and job log tables for scheduled tasks |
rails generate catalyst:add_comments_with_mentions | Adds commenting system with @mentions support |
rails generate catalyst:add_ct_support_ticket | Sets up support ticket system for customer requests |
rails generate catalyst:add_ct_platform_setting | Creates platform settings table for app configuration |
rails generate catalyst:add_ct_index_preference | Adds user-customizable column preferences for lists |
rails generate catalyst:add_cron_job_notifications | Creates notification system for cron job alerts |
rails generate catalyst:add_prompts_with_constants | Adds Lexxy rich text templates with category support |
rails generate catalyst:add_token_type_to_api_token | Migration to add token types to API tokens |
rails generate catalyst:add_name_to_api_token | Migration to add a name field to API tokens |
rails generate catalyst:remove_status_from_api_token | Drops api_tokens.status; expiry is derived from expires_at |
rails generate catalyst:add_unique_index_to_permissions | Migration to prevent duplicate permissions |
rails generate catalyst:file_import_improvement | Migration to add tracking columns to file imports |
rails generate catalyst:file_export_improvement | Migration to upgrade file export functionality |
rails generate catalyst:add_audit_metadata_to_versions | Adds action_type and action_name columns to PaperTrail versions |
rails generate catalyst:add_otp_requests | Creates otp_requests table for OTP-based authentication |
rails generate catalyst:add_email_logs | Creates the ct_email_logs table for recording Catalyst.send_email deliveries |
rails generate catalyst:rename_file_import_and_export_tables | Rename file_imports and file_exports tables |
rails generate catalyst:add_webhook_events | Creates the ct_webhook_events table for webhook logging |
rails generate catalyst:add_webhook_event_recipient | Adds recipient link and original_link columns to ct_webhook_events |
rails generate catalyst:ct_page_view | Creates ct_page_views table for Saved Views (replaces index preferences) |
rails generate catalyst:add_bot_conversations | Creates the tables for the Catalyst AI (CT Bot) chat feature |
rails generate catalyst:add_bot_transcriptions | Creates the ct_bot_transcriptions table for Catalyst AI voice input |
rails generate catalyst:add_ruby_llm_persistence | Upgrades an existing Catalyst AI install to RubyLLM persistence tables |
rails generate catalyst:add_trackable_columns | Adds created_by_id / updated_by_id to models that include Trackable |
rails generate catalyst:ct_cron_improvements | Adds notification_emails to ct_cron_jobs |
rails generate catalyst:form_draft | Creates the ct_form_drafts table used by progressive forms |
rails generate catalyst:add_mcp_oauth | Creates the OAuth tables that let MCP clients sign in without a PAT |
Copying All Pending Migrationsβ
Instead of running each generator by hand, you can copy every Catalyst migration your app is missing in one command:
rails catalyst:install_migrations
This detects the same pending migrations the development boot warning lists ("The following Catalyst migrations may not be applied") and generates them into db/migrate β it does not run db:migrate, so you can review the files and apply them yourself. Migrations the app already has a file for are not reported as pending, templates superseded by a later migration (like create_ct_index_preferences, whose table ct_page_view drops) are left out, and templates that need generator-specific input are skipped with a hint to run their generator instead.
The generated files are versioned so that a migration always runs after the migrations creating the tables its foreign keys point at (for example create_ct_cron_jobs before create_ct_cron_job_logs). Migrations that add columns to a Catalyst table are only reported once that table exists, so on a fresh app run the task again after rails db:migrate.
Core Generatorsβ
Install Generatorβ
Command:
rails generate catalyst:install
What it does:
- Installs Action Text for rich text editing
- Creates the Catalyst initializer (
config/initializers/catalyst.rb) - Sets up custom JavaScript and CSS files
- Creates the application policy for authorization
- Mounts the Catalyst engine in routes
- Creates migrations for the
ct_file_imports,ct_file_exportsandct_index_preferencestables - Installs i18n ActiveRecord for translations
- Runs database migrations
Why you need it: This is the essential first step when setting up Catalyst. It creates the foundation that all other features depend on.
Install Role Generatorβ
Command:
rails generate catalyst:install_role
What it does:
- Creates migration for Catalyst::Role (roles table)
- Creates migration for Catalyst::Permission (permissions table)
- Creates a default "Admin" role
- Automatically assigns all available permissions to the Admin role for all configured models
Why you need it: Enable role-based access control (RBAC) in your admin panel. This allows you to define different user roles with specific permissions.
Install User Groups Generatorβ
Command:
rails generate catalyst:install_user_groups
What it does:
- Creates migrations for
ct_user_groupsand thect_roles_user_groupsjoin table - Runs the migrations
- Seeds the default platform settings, including Enable User Groups (
Catalyst::PlatformSetting.add_ct_default_settings)
Why you need it:
Group users and assign roles to groups. Requires install_role and add_ct_platform_setting first.
Add Authentication Generatorβ
Command:
rails generate catalyst:add_authentication
What it does:
- Adds Devise gem to your Gemfile
- Installs and configures Devise
- Prompts for the user model name (defaults to "user")
- Creates the user model with Devise
- Sets up application controller with authentication
- Creates authentication concern
- Creates Current model for thread-safe context
- Adds
super_admin?method to the user model
Why you need it: Use this when your application doesn't have an authentication system yet. It quickly sets up Devise-based authentication with Catalyst integration.
Feature Generatorsβ
Add GraphQL Generatorβ
Command:
rails generate catalyst:add_graphql
What it does:
- Adds GraphQL-related gems (graphql, graphql-errors, graphql-rails_logger)
- Installs GraphQL Rails
- Creates GraphQL schema
- Sets up type directories (inputs, enums, objects)
- Creates base mutation and query classes
- Sets up model concerns
- Creates exception handling
Why you need it: Enable GraphQL API for your application. Useful when you need a flexible API for external integrations or modern frontend frameworks.
Add Scheduler Generatorβ
Command:
rails generate catalyst:add_scheduler
What it does:
- Creates migration for Catalyst::CronJob (scheduled jobs)
- Creates migration for Catalyst::CronJobLog (job execution logs)
Next steps:
- Add
Catalyst::CronJob, Catalyst::CronJobLogtoconfig.included_modelsincatalyst.rb - Run
rails db:migrate - Start Sidekiq for background job processing
Why you need it: Add cron job management to your admin panel. Schedule and monitor recurring background jobs directly from the admin interface.
Add Comments with Mentions Generatorβ
Command:
rails generate catalyst:add_comments_with_mentions
What it does:
- Creates migration for Catalyst::Comment (comments table)
- Creates migration for Catalyst::UserMention (user mentions in comments)
Next steps:
- Run
rails db:migrate
Why you need it: Enable commenting with @mentions functionality. Users can comment on records and tag other users with @mentions for notifications.
Add CT Support Ticket Generatorβ
Command:
rails generate catalyst:add_ct_support_ticket
What it does:
- Creates migration for Catalyst::SupportTicket
- Creates migration for Catalyst::SupportTicketEmployee (ticket assignments)
- Creates migration adding created_by to Catalyst::Comment
Next steps:
- Add
Catalyst::SupportTickettoconfig.included_modelsincatalyst.rb - Run
rails db:migrate
Why you need it: Set up a support ticket system within your admin panel. Manage customer support requests and assign them to team members.
Add CT Platform Setting Generatorβ
Command:
rails generate catalyst:add_ct_platform_setting
What it does:
- Creates migration for Catalyst::PlatformSetting (platform-wide settings)
Next steps:
- Run
rails db:migrate
Why you need it: Add platform settings management to your admin panel. Store and manage application-wide configuration values.
Add CT Index Preference Generatorβ
Command:
rails generate catalyst:add_ct_index_preference
What it does:
- Creates migration for Catalyst::IndexPreference (user column preferences)
- Creates constants initializer
Next steps:
- Run
rails db:migrate
Why you need it: Allow users to customize which columns appear in list views. Each user can save their preferred column visibility and order.
Add Cron Job Notifications Generatorβ
Command:
rails generate catalyst:add_cron_job_notifications
What it does:
- Creates migration for Catalyst::Notifiable (notification system)
Next steps:
- Run
rails db:migrate - Add to your models:
has_many :notifiables, as: :notifiable, dependent: :destroyaccepts_nested_attributes_for :notifiables, allow_destroy: true
Why you need it: Enable unified notification system for cron jobs. Send email and webhook notifications when scheduled jobs complete or fail.
Add Prompts with Constants Generatorβ
Command:
rails generate catalyst:add_prompts_with_constants
What it does:
- Creates migration for Catalyst::Prompt (rich text templates)
- Creates migration for ConstantMap (polymorphic associations)
- Adds Lexxy template platform setting
- Enables AI-powered slash commands in rich text editors
Next steps:
- Add
Catalyst::Prompttoconfig.included_modelsincatalyst.rb - Run
rails db:migrate - Ensure Lexxy gem is installed (~> 0.8)
Why you need it:
Add AI-powered rich text templates to your admin panel. Users can create reusable prompt templates with category-based filtering and access them via slash commands (/) in any rich text field.
Migration Generators (Upgrades)β
Add Token Type to API Token Generatorβ
Command:
rails generate catalyst:add_token_type_to_api_token
What it does:
- Creates migration to add token_type column to API tokens
Why you need it: Upgrade existing installations to support different token types (e.g., read-only, read-write) for API authentication.
Add Unique Index to Permissions Generatorβ
Command:
rails generate catalyst:add_unique_index_to_permissions
What it does:
- Creates migration to add unique index on ct_permissions table
Why you need it: Database integrity upgrade to prevent duplicate permission entries.
File Import Improvement Generatorβ
Command:
rails generate catalyst:file_import_improvement
What it does:
- Creates migration to add
action_name,importer_class_name,import_type, andassociated_model_idcolumns to the file_imports table
Next steps:
- Run
rails db:migrate
Why you need it: Upgrade existing installations to store import metadata directly on the file import record. This enables the job processor to work without relying on runtime model lookups and provides better traceability in the file imports index and show views.
File Export Improvement Generatorβ
Command:
rails generate catalyst:file_export_improvement
What it does:
- Creates migration to improve file export functionality
- Runs the migration automatically
Why you need it: Upgrade existing installations to the improved file export system with better performance and features.
Add Audit Metadata to Versions Generatorβ
Command:
rails generate catalyst:add_audit_metadata_to_versions
What it does:
- Creates a migration to add
action_typeandaction_namecolumns to the PaperTrailversionstable - Adds indexes on both columns for fast audit filtering
- Checks that the
versionstable exists before generating the migration - Only adds columns that are not already present
Next steps:
- Run
rails db:migrate
Why you need it:
Upgrade existing installations to record queryable audit metadata on every PaperTrail version. Catalyst uses these columns to store which admin action (CRUD, custom action, or bulk action) triggered a change. Required for the auditing feature described in Auditing.
Add OTP Requests Generatorβ
Command:
rails generate catalyst:add_otp_requests
What it does:
- Creates migration for
otp_requeststable with columns:otp,email(citext),expired_at,status,verified_at,user_id(optional foreign key), and timestamps - Adds an index on the
emailcolumn - Prints post-install instructions reminding you to add
has_many :otp_requeststo your User model
Next steps:
- Run
rails db:migrate - Add to your User model:
has_many :otp_requests, dependent: :destroy, class_name: "Catalyst::OtpRequest"
- Enable in
catalyst.rb:config.auth_method = :otp # or :password, :custom
Why you need it:
Set up OTP-based authentication in your admin panel. The otp_requests table stores one-time codes with expiry and status tracking. Supports both user-associated OTPs and email-only OTPs (for signup flows without a user record). See OtpAndAuth for the full setup guide.
CT Page View Generatorβ
Command:
rails generate catalyst:ct_page_view
What it does:
- Enables the PostgreSQL
citextextension if needed - Drops the legacy
ct_index_preferencestable if it exists (data is not migrated) - Creates the
ct_page_viewstable with:owneras a required polymorphic referencename(citext, required)ar_model_name,associated_ar_model_name,visible_columns,hidden_columns,records_per_pageis_default, plus a partial unique index allowing one default view per owner / modelview_type(integer enum: table, card, kanban)filter_params(jsonb) andsort_params(json), both defaulting to{}
Next steps:
- Run
rails db:migrate
Why you need it:
Powers Saved Views: per-user saved filters (including Advanced Filters), sort, columns, page size, and view type. Replaces Index Preference.
Add Email Logs Generatorβ
Command:
rails generate catalyst:add_email_logs
What it does:
- Creates the
ct_email_logstable used to record everyCatalyst.send_emaildelivery whenconfig.enable_email_loggingistrue.
Next steps:
- Run
rails db:migrate
Why you need it:
Enable email delivery logging for your admin panel. This stores delivery status, recipients, failure reasons, and record associations, which is useful for auditing and debugging outgoing emails. See Email for the full email sending API.
Rename File Import and Export Tables Generatorβ
Command:
rails generate catalyst:rename_file_import_and_export_tables
What it does:
- Creates a reversible migration that renames
file_importstoct_file_importsandfile_exportstoct_file_exports - Updates persisted model names from
FileImportandFileExporttoCatalyst::FileImportandCatalyst::FileExportin Active Storage, PaperTrail, permissions, and index preferences
Next steps:
- Run
rails db:migrate - Replace application references to
FileImportandFileExportwithCatalyst::FileImportandCatalyst::FileExport
Why you need it:
Use this generator when upgrading an existing installation to the Catalyst::FileImport and Catalyst::FileExport model names.
Add Webhook Events Generatorβ
Command:
rails generate catalyst:add_webhook_events
What it does:
- Creates the
ct_webhook_eventstable used to log incoming webhook events whenconfig.enable_webhook_processingistrue - Adds columns for
ct_service(gem-managed service enum, e.g.postmark),host_service(host-app service enum),event_type,status,event_id,uuid(auto-assigned viaSecureRandom, unique index),error_message,processed_at, and a polymorphiceventableassociation - Adds indexes on status, both services, event type, event ID, UUID (unique), created date, the
eventableassociation, and composite service + event ID + event type lookups
Next steps:
- Run
rails db:migrate - Ensure ActiveStorage is installed and configured (
rails active_storage:install) β webhook payloads are stored asraw_payloadattachments
Why you need it:
Enable webhook logging for your admin panel. Incoming webhooks are persisted with their payload, status, and error information, and processed asynchronously via ProcessWebhookEventJob. See Webhooks for the full webhook setup guide.
Add Webhook Event Recipient Generatorβ
Command:
rails generate catalyst:add_webhook_event_recipient
What it does:
- Adds a polymorphic
recipientassociation (recipient_type/recipient_id+ index) toct_webhook_eventsβ links each event to the recipient it belongs to, populated at webhook receipt by matching the payload's recipient email against the log's record - Adds an
original_linkcolumn β for Click events, the clicked URL, denormalized at receipt so clicks can be grouped and counted in SQL
Next steps:
- Run
rails db:migrate
Why you need it:
For installations that already ran add_webhook_events. Per-recipient open/click tracking (recipient columns, Click Details, Events tab, campaign engagement metrics) depends on these columns. The migration is idempotent β it skips columns that already exist, so it is safe to run more than once.
Add Name to API Token Generatorβ
Command:
rails generate catalyst:add_name_to_api_token
What it does:
- Creates a migration to add a
namestring column to theapi_tokenstable - Backfills existing records with
'Unnamed Token'so every token is identifiable - Drops the legacy
descriptioncolumn if it exists (added by v8.2.14'sadd_description_to_api_token)
Next steps:
- Run
rails db:migrate
Why you need it:
Upgrade existing installations to give every API token a mandatory, human-readable name (max 100 characters), making it easier to identify what each token is used for and to search tokens by name.
Add Bot Conversations Generatorβ
Command:
rails generate catalyst:add_bot_conversations
What it does:
- Creates migration for the
ruby_llm_*persistence tables (ruby_llm_models,ruby_llm_tool_calls,ruby_llm_mcp_credentials,ruby_llm_usages,ruby_llm_queued_messages,ruby_llm_chat_files,ruby_llm_batches,ruby_llm_provider_files) thatacts_as_chat/acts_as_messageuse to store chats, tool calls, usage and queued messages - Creates migration for
ct_bot_conversations(chat conversations per user, linked to aruby_llm_modelsrow, with the run-claim columnscancelled,claim_tokenandclaimed_until) - Creates migration for
ct_bot_messages(messages with rich text content andattachments, a stringroleβuser/assistant/system/toolβ and assistant metadata columns such as thinking text, citations and finish reason) - Creates migration for
ct_bot_artifacts(interactive elements such as clarifying-question and confirmation cards) - Creates migration adding
is_catalyst_ai_enabledtoct_roles(per-role opt-in flag)
Next steps:
- Add
Catalyst::BotConversation, Catalyst::BotMessage, RubyLlmUsagetoconfig.included_modelsincatalyst.rb - Upgrading an existing Catalyst AI install? Don't rerun this generator β run
catalyst:add_ruby_llm_persistenceinstead (below) - Run
rails db:migrate - Add your OpenRouter key to credentials:
catalyst_ai.openrouter_api_key - Ensure
config/cable.ymlexists (Redis adapter recommended in production) β replies stream over ActionCable - Declare
mcp_actionson the models the assistant may query - Enable Catalyst AI on each
Catalyst::Rolethat should see the widget
Why you need it:
Sets up Catalyst AI (CT Bot) β an in-app chat widget that answers admin users' questions using your MCP-enabled models. See Catalyst AI for the full feature guide.
Add Bot Transcriptions Generatorβ
Command:
rails generate catalyst:add_bot_transcriptions
What it does:
- Creates migration for
ct_bot_transcriptions(voice recordings with their transcribed text, status and cost, optionally linked to a conversation and message)
Next steps:
- Add
Catalyst::BotTranscriptiontoconfig.included_modelsincatalyst.rb - Run
rails db:migrate
Why you need it:
Enables voice input in the Catalyst AI chat widget (added in v8.4.1). Run it after add_bot_conversations β on existing Catalyst AI installs and fresh installs alike. See the v8.4.1 upgrade guide.
Remove Status from API Token Generatorβ
Command:
rails generate catalyst:remove_status_from_api_token
What it does:
- Stamps
expires_atwith the current time on tokens stored asexpiredthat would otherwise still be valid by date, so none are re-enabled - Drops the
statuscolumn fromapi_tokens - The
downmigration re-addsstatusand marks tokens whoseexpires_athas passed asexpired
Next steps:
- Replace
enum :status, %i[live expired]in yourApiTokenmodel with the derived scopes and methods (the Catalyst API Tokens pages callstatusandlive?):
scope :live, -> { where(expires_at: [nil, Time.current..]) }
scope :expired, -> { where(expires_at: ...Time.current) }
def live?
expires_at.nil? || expires_at.future?
end
def expired?
!live?
end
def status
live? ? "live" : "expired"
end
- Run
rails db:migrate
Why you need it:
Whether an API token is live is now derived only from expires_at. ApiToken#status, #live?, #expired? and the live / expired scopes are computed from it.
Add Ruby LLM Persistence Generatorβ
Command:
rails generate catalyst:add_ruby_llm_persistence
What it does:
- Creates the
create_ruby_llm_recordsmigration for theruby_llm_*persistence tables - Creates the
add_ruby_llm_persistence_to_ct_botmigration, which renames messagefilesattachments toattachmentsand links existing conversations to the default bot model inruby_llm_models
Next steps:
- Run
rails db:migrate
Why you need it:
Upgrade existing Catalyst AI installations that ran add_bot_conversations before RubyLLM persistence was added. Fresh installs get these tables from add_bot_conversations and don't need it. See Catalyst AI.
Add Trackable Columns Generatorβ
Command:
rails generate catalyst:add_trackable_columns
What it does:
- Eager-loads the app and finds every model that includes
Trackablebut is missingcreated_by_idorupdated_by_id - Creates one migration (
add_trackable_columns_to_models, or_v2,_v3β¦ if one already exists) that adds the missing columns
Next steps:
- Run
rails db:migrate
Why you need it:
Records which user created and last updated each record. See Trackable.
CM Cron Improvements Generatorβ
Command:
rails generate catalyst:ct_cron_improvements
What it does:
- Creates a migration that adds
notification_emailstoct_cron_jobs - Runs the migration automatically
Why you need it:
Upgrade existing installations so each cron job can list the emails notified about its runs. See Cron Jobs.
Form Draft Generatorβ
Command:
rails generate catalyst:form_draft
What it does:
- Creates the
create_ct_form_draftsmigration
Next steps:
- Run
rails db:migrate
Why you need it:
Progressive (multi-step) forms store each step's values in ct_form_drafts. See Progressive Forms.
Add MCP OAuth Generatorβ
Command:
rails generate catalyst:add_mcp_oauth
What it does:
- Creates the
create_ct_oauth_tablesmigration (ct_oauth_clients,ct_oauth_grants,ct_oauth_tokens) ct_oauth_clientsholds both registered clients and clients identified by a Client ID Metadata Document, withmetadata_fetched_atandmetadata_expires_attracking when a document was last fetched
Next steps:
- Run
rails db:migrate - Set
config.mcp_oauth_enabled = true
Why you need it:
Lets MCP clients such as Claude connect by signing in through the browser. See MCP Server.
Recommended Setup Orderβ
For new projects, run generators in this order:
rails generate catalyst:install- Foundation setuprails generate catalyst:add_authentication- If no auth existsrails generate catalyst:add_otp_requests- For OTP-based authrails generate catalyst:install_role- For role-based permissionsrails generate catalyst:file_import_improvement- Add tracking columns to file imports- Feature generators as needed (scheduler, comments, support tickets, etc.)
Troubleshootingβ
Missing models: After running feature generators, remember to add the new models to config.included_models in catalyst.rb.