Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/crashtech/torque-admin/llms.txt

Use this file to discover all available pages before exploring further.

This guide takes you from a bare Rails 8.1 application to a live admin interface that manages a real ActiveRecord model. By the end you will have a dashboard at /admin, a fully routed Post resource with index, show, new, create, edit, update, and destroy actions, and streamed page delivery via Hotwire — all without writing a single view template.

Prerequisites

  • An existing Rails 8.1+ application
  • At least one ActiveRecord model — this guide uses Post (generated with rails g model Post title:string body:text)
  • Ruby 3.2.0 or later
1

Add the gem and bundle

Add torque-admin to your Gemfile:
Gemfile
gem 'torque-admin'
Then install it:
bundle install
Torque::Admin::Railtie is loaded automatically during Rails boot. It extends ActionDispatch::Routing::Mapper with the admin routing helper and registers the engine’s eager-load namespace — no manual require needed.
2

Declare routes in config/routes.rb

Open config/routes.rb and use the admin routing helper to mount the engine and declare your resource:
config/routes.rb
Rails.application.routes.draw do
  # All other application routes …

  admin do
    resources :posts
  end
end
The admin block does three things in one call:
  1. Mounts Admin::Engine at /admin (the default path)
  2. Opens a routing scope against the engine’s internal router
  3. Registers posts as a resource within the admin application so it appears in navigation and breadcrumbs
This generates the standard seven RESTful routes — admin_posts_path, admin_post_path, etc. — all namespaced under the engine.
3

Create Admin::BaseController

Torque Admin does not generate base classes for you. Create the base controller for your admin namespace:
app/controllers/admin/base_controller.rb
module Admin
  class BaseController < ApplicationController
    include Torque::Admin::BaseController
  end
end
Including Torque::Admin::BaseController pulls in four key concerns in one line:
  • Elements::Frame — handles Turbo frame detection and streaming context
  • Elements::Templates — drives the Element template resolution pipeline
  • Elements::Controller — exposes the element and main_menu class-level DSL
  • SettingsController — provides per-request access to admin configuration and UI builder
The concern also appends the engine’s own view path and sets the Rails layout to admin, so app/views/layouts/admin.html.erb in your host application is used if it exists, with the engine’s built-in layout as a fallback.
Before exposing your admin in production, add authentication to Admin::BaseController. For example, with Devise you can add before_action :authenticate_user!. See Authentication Configuration for strategies including Devise, Rodauth, and custom session checks.
4

Create Admin::PostsController

Now create a controller for the Post resource:
app/controllers/admin/posts_controller.rb
module Admin
  class PostsController < Admin::BaseController
    include Torque::Admin::ResourceController
  end
end
Including Torque::Admin::ResourceController composes all seven CRUD concerns automatically — you do not need to define index, show, new, create, edit, update, or destroy yourself. Under the hood it includes:
ConcernResponsibility
StreamControllerStreams response chunks via ActionController::Live
CollectionControllerScoping, filtering, sorting, and pagination for collection actions
MemberControllerRecord lookup and parameter assignment for member actions
IndexControllerindex action implementation
ShowControllershow action implementation
FormControllernew, create, edit, update implementations
BatchControllerBulk-action support
ActionsControllerCustom member and collection action helpers
WidgetsControllerDashboard widget rendering
The concern also looks up the RESOURCE constant (set by the engine’s routing layer) so that PostsController::RESOURCE resolves to the Admin::Resource object for Post, giving you access to the model class, singular/plural names, and registered sections.
stream_actions is true by default, which means index and show are automatically wired to stream their response chunks using ActionController::Live. Each section of the page — header, filters, table body, pagination — is flushed to the browser as it becomes ready. You can disable streaming globally by setting config.stream_actions = false in your admin configuration, or per-controller by not calling stream_from_actions.
5

Visit /admin in the browser

Start your Rails server:
bin/rails server
Navigate to http://localhost:3000/admin. Torque Admin automatically generates a dashboard root route, so the homepage renders immediately. Then visit http://localhost:3000/admin/posts to see the streamed index view for your Post resource, complete with table, pagination, and action buttons.

What You Just Built

After completing these steps your application has:
  • An admin engine mounted at /admin with its own isolated routes and helpers
  • A Post resource registered with Torque Admin, available at /admin/posts
  • Full CRUD without a single action method written by hand
  • Streamed index and show pages delivered via Hotwire and ActionController::Live

Explore Further

Resource Concepts

Understand how Torque Admin models resources, resolves controllers, and builds navigation entries from your route declarations.

Configuration Overview

Customise the theme, enable or disable streaming, configure authentication defaults, and tune parallel processing.

Build docs developers (and LLMs) love