Installation
Add Catalyst to an existing Rails app and mount it at /admin.
Requirementsβ
| Requirement | Version |
|---|---|
| Ruby | 3.3 or later |
| Rails | 8.0 or later |
| Node.js | Needed at build time: assets:precompile compiles Catalyst's CSS with Dart Sass (CSS bundler) |
| PaperTrail | Needed for roles and record history (paper_trail gem) |
1. Add the gemβ
source "https://gems.betterplatforms.dev" do
gem "better-platforms-catalyst"
end
Keep the source block: an unrelated gem called catalyst is published on rubygems.org.
bundle install
2. Run the install generatorβ
rails generate catalyst:install
This installs Action Text and i18n-active_record, mounts the engine at /admin, creates config/initializers/catalyst.rb, app/policies/application_policy.rb and the catalyst/custom.js / custom.css assets, and runs the file import/export migrations. See the Install generator for the full list.
3. Set up authenticationβ
Catalyst reads the signed-in user from Current.user.
- No authentication yet? Run
rails generate catalyst:add_authentication. It sets up Devise, anAuthenticationconcern and theCurrentmodel. - OTP login? Use the built-in flow: see Authentication & OTP.
- Existing auth? Set
Current.userin abefore_actionof your admin controllers.
4. Set up roles and permissionsβ
rails generate catalyst:install_role
rails generate migration AddCtRoleToUser ct_role:references
rails db:migrate
This creates Catalyst::Role and Catalyst::Permission and an Admin role with every permission. Assign a role to your user (user.update!(ct_role: Catalyst::Role.find_by(name: "Admin"))). See Roles & Permissions.
5. Copy any remaining migrationsβ
rails catalyst:install_migrations
rails db:migrate
Verifyβ
Start the server and open http://localhost:3000/admin. After signing in you should see the Catalyst dashboard.
Missing a model in the sidebar? Every model must be listed in config.included_models in config/initializers/catalyst.rb.