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 atDocumentation 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.
/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 withrails g model Post title:string body:text) - Ruby 3.2.0 or later
Add the gem and bundle
Add Then install it:
torque-admin to your Gemfile:Gemfile
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.Declare routes in config/routes.rb
Open The
config/routes.rb and use the admin routing helper to mount the engine and declare your resource:config/routes.rb
admin block does three things in one call:- Mounts
Admin::Engineat/admin(the default path) - Opens a routing scope against the engine’s internal router
- Registers
postsas a resource within the admin application so it appears in navigation and breadcrumbs
admin_posts_path, admin_post_path, etc. — all namespaced under the engine.Create Admin::BaseController
Torque Admin does not generate base classes for you. Create the base controller for your admin namespace:Including
app/controllers/admin/base_controller.rb
Torque::Admin::BaseController pulls in four key concerns in one line:Elements::Frame— handles Turbo frame detection and streaming contextElements::Templates— drives the Element template resolution pipelineElements::Controller— exposes theelementandmain_menuclass-level DSLSettingsController— provides per-request access to admin configuration and UI builder
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.Create Admin::PostsController
Now create a controller for the Including
The concern also looks up the
Post resource:app/controllers/admin/posts_controller.rb
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:| Concern | Responsibility |
|---|---|
StreamController | Streams response chunks via ActionController::Live |
CollectionController | Scoping, filtering, sorting, and pagination for collection actions |
MemberController | Record lookup and parameter assignment for member actions |
IndexController | index action implementation |
ShowController | show action implementation |
FormController | new, create, edit, update implementations |
BatchController | Bulk-action support |
ActionsController | Custom member and collection action helpers |
WidgetsController | Dashboard widget rendering |
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.Visit /admin in the browser
Start your 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
/adminwith its own isolated routes and helpers - A
Postresource 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.
