Reusable Rails engine for a CMS-style admin: permissions, admin UI shell, content blocks, and a visual editor.
Vision: your app owns product features (pages, models, business logic); RubyCMS manages content workflows and admin screens.
This README is an overview and quick start. For a full, versioned checklist of admin routes, rake tasks, and integrations, see docs/FEATURES.md. Use a GitHub Wiki only if you want long, site-specific runbooks; keep the gem’s canonical list in-repo to avoid drift.
- Visual editor (inline editing for
content_blockregions) - Content blocks (rich text + placeholders + list items)
- Permissions and users (admin access control)
- Admin settings (DB-backed options, nav order)
- Visitor error tracking (
/admin/visitor_errors) - Analytics via Ahoy (dashboard, page and visitor drill-downs)
rails g ruby_cms:installThe generator sets up:
config/initializers/ruby_cms.rb- mounts the engine (
/admin/...on the host app) - migrations + RubyCMS tables
- seed permissions + initial admin setup
If your host app already has /admin routes, adjust/remove them so RubyCMS can use /admin.
In any view:
<%= content_block("hero_title", default: "Welcome") %>
<%= content_block("footer", cache: true) %>Placeholders (attributes like `placeholder`, `alt`, meta tags)
content_block wraps output for the visual editor, so do not put it inside HTML attributes.
Use wrap: false (or content_block_text):
<%= text_field_tag :name, nil,
placeholder: content_block("contact.name_placeholder", wrap: false, fallback: "Your name") %>
<%= text_area_tag :message, nil,
placeholder: content_block_text("contact.message_placeholder", fallback: "Your message...") %>List items (badges, tags, arrays)
Use content_block_list_items to get an Array:
<% content_block_list_items("education.item.badges", fallback: item[:badges]).each do |badge| %>
<%= tag.span badge, class: "badge" %>
<% end %>Store list content as JSON (["Ruby", "Rails"]) or newline-separated text in the CMS.
Create/edit blocks in Admin -> Content blocks.
Configure preview templates + (optional) preview data in config/initializers/ruby_cms.rb:
c.preview_templates = { "home" => "pages/home", "about" => "pages/about" }
c.preview_data = ->(page_key, view) { { products: Product.limit(5) } }Then open Admin -> Visual editor, pick a page key, and click content blocks in the preview.
RubyCMS exposes an admin_page helper:
<%= admin_page(title: "My Page", subtitle: "Optional") do %>
<p>Hello from RubyCMS admin.</p>
<% end %>Public (non-admin) exceptions are captured and shown in /admin/visitor_errors.
In development, logging is typically disabled and exceptions are re-raised normally.
Include RubyCms::PageTracking in public controllers:
class PagesController < ApplicationController
include RubyCms::PageTracking
def home
# @page_name can be set; defaults vary by controller
end
endIf you want to import blocks from locales, set:
c.content_blocks_translation_namespace = "content_blocks"Example config/locales/en.yml:
en:
content_blocks:
hero_title: "Welcome to my site"Import:
rails ruby_cms:content_blocks:seedrails ruby_cms:seed_permissionsrails ruby_cms:setup_adminrails ruby_cms:content_blocks:seed