Skip to main content

Views

Every model you register gets a set of pages: an index listing, a show page and new/edit/delete forms. You declare them in a cm_admin block, usually in a concern under app/models/concerns/cm_admin/.

Quick example​

app/models/concerns/cm_admin/blog_post.rb
module CmAdmin
module BlogPost
extend ActiveSupport::Concern

included do
cm_admin do
actions only: %i[index show new create edit update destroy history]
icon_name "fa-solid fa-newspaper"

cm_index do
column :title
end
cm_show do
tab :profile, "" do
cm_section "Details" do
field :title
end
end
end
end
end
end
end
app/models/blog_post.rb
class BlogPost < ApplicationRecord
has_paper_trail
include CmAdmin::BlogPost
end

Then add BlogPost to config.included_models in config/initializers/cm_admin.rb. Its pages are served under /admin/blog_posts.

Model settings​

Call these directly inside cm_admin do ... end.

MethodDefaultDescription
actionsall default actionsactions only: [...] or actions except: [...]. See Default actions.
icon_name"fa fa-th-large"Font Awesome icon shown in the sidebar.
display_nameModel name, titleizedName shown in the sidebar.
visible_on_sidebartrueSet false to hide the model from the sidebar and global search while keeping its pages.
descriptionnilModel description returned to AI clients by the MCP server.
policy_scopes[Full Access]Extra permission scopes. See Roles & Permissions.
comments_tabnoneAdds a comments tab. See Comments & Mentions.
global_search_fieldsnoneFields searched by Global Search.

Default actions​

ActionRoutePage
indexGET /Index page
showGET /:idShow page
new / createGET /new, POST /New page
edit / updateGET /:id/edit, PATCH /:idEdit page
destroyDELETE /:idDelete
historyGET /:id/historyRecord history. Needs has_paper_trail on the model (Auditing).
exportPOST /export_to_fileCSV/XLSX export from the index page.
warning

Listing :history in actions only: on a model without has_paper_trail raises at boot in development and test, and logs a warning elsewhere.

These work inside any view block (cm_index, cm_show, cm_new, …).

MethodArgumentsDescription
page_titletitlePage title.
page_descriptiondescriptionShown below the title. Accepts HTML (formatting, lists, links); media is stripped, links open in a new tab, and long text is clamped to two lines with View more / View less.
title_iconicon_name:, url:, tooltip: nil, display_if: nilIcon button next to the title linking to url in a new tab. Renders only when both icon_name and url are set.
cm_index do
page_title "Posts"
page_description "<p>All posts. <strong>Drafts</strong> are only visible to editors.</p>"
title_icon icon_name: "fa-solid fa-circle-info", url: "https://example.com/tutorial", tooltip: "Click to view tutorial"
end