Rails Tiptap Autosave logo

Rails Tiptap Autosave

Community
obie
rails-tiptap-autosave

Add Tiptap rich text editing with debounced autosave to Rails models using Stimulus. Stores markdown in text columns (not ActionText). Covers installation, Stimulus controller, shared partials, Turbo cache handling, and optional change tracking.

Overview

Publisherobie
Repositoryskills
Skill namerails-tiptap-autosave
Stars
101
Forks
6
Bundled files
4
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 4 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by obie on GitHub. Read the source before you install it.

Installation

Install the Rails Tiptap Autosave AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/obie/skills/tree/main/skills/rails-tiptap-autosave
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/obie/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/skills/rails-tiptap-autosave .claude/skills/rails-tiptap-autosave
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Rails Tiptap Autosave in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Rails Tiptap Autosave on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Rails Tiptap Autosave is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Rails Tiptap Autosave

Add rich text editing with automatic background saving to any Rails model using Tiptap, Stimulus, and markdown stored in plain text columns.

When to Use This Skill

Invoke this skill when:

  1. Adding rich text editing to Rails models without ActionText
  2. Implementing inline autosave for text fields
  3. Integrating Tiptap editor with Stimulus controllers
  4. Building content editing UIs with formatting toolbars
  5. Debugging Tiptap + Turbo cache conflicts

Architecture Overview

Key decision: Markdown in text columns, NOT ActionText.

Why this approach:

  • No extra tables or polymorphic attachments
  • Content is plain text -- easy to query, diff, and version
  • Markdown renders cleanly in non-browser contexts (emails, APIs, CLI)
  • Simpler mental model than ActionText's rich text blobs

How it works:

  1. Tiptap editor (initialized via Stimulus) converts user input to markdown
  2. On every keystroke (debounced 1 second), PATCH to autosave endpoint
  3. Controller saves markdown to a text column via update_column
  4. Status indicator shows "Saving..." -> "Saved" -> fades

Key Files

FilePurpose
app/javascript/controllers/rich_text_editor_controller.jsTiptap Stimulus controller
app/views/shared/_rich_text_field.html.erbReusable editor partial
app/views/shared/_bubble_menu.html.erbFormatting toolbar

Core Patterns

1. Installation & Build Pipeline

npm packages, @rails/request.js for CSRF, JS bundler setup (Tiptap does NOT work with importmap), and editor CSS.

See: references/installation.md

2. Stimulus Controller

The full rich_text_editor_controller.js -- handles Tiptap initialization, debounced autosave, BubbleMenu target relocation, Turbo cache cleanup, and bubble menu formatting commands.

See: references/stimulus-controller.md

3. View Partials

Reusable _rich_text_field.html.erb and _bubble_menu.html.erb partials with Stimulus data attributes.

See: references/partials.md

4. Optional Audit Trail

Debounced change tracking that groups rapid edits into single audit events.

See: references/audit-trail.md

Adding Rich Text to a Model

Quick step-by-step for any model (Article, Post, Page, etc.):

Step 1: Add a text column

ruby
class AddBodyToArticles < ActiveRecord::Migration[7.1]
  def change
    add_column :articles, :body, :text
  end
end

Use text, NOT string. The string type has a 255-character limit -- far too small for rich text content.

Step 2: Add the autosave route

ruby
# config/routes.rb
resources :articles do
  member do
    patch :autosave
  end
end

Step 3: Add the autosave controller action

ruby
class ArticlesController < ApplicationController
  before_action :set_article, only: [:show, :edit, :update, :autosave]

  AUTOSAVE_FIELDS = %w[body summary notes].freeze

  def autosave
    field = params[:field].to_s
    unless AUTOSAVE_FIELDS.include?(field)
      return render json: { error: "field not allowed" }, status: :bad_request
    end

    @article.update_column(field.to_sym, params[:value])
    render json: { status: "saved" }
  end
end

Key details:

  • update_column bypasses validations and callbacks -- important for autosave performance
  • Field whitelist prevents saving to arbitrary columns (security)
  • Returns JSON (not HTML) since this is a background save
  • set_article must include :autosave in the only: list

Step 4: Render the shared partial in your view

erb
<%= render "shared/rich_text_field",
    url: autosave_article_path(@article),
    field: "body",
    content: @article.body,
    placeholder: "Write your article...",
    label: "Body",
    subtitle: "-- supports markdown formatting" %>

Common Pitfalls

  1. Wrong column type: Must be text, not string (255 char limit will silently truncate content)
  2. Missing route: patch :autosave member route must exist or you get 404s on save
  3. Missing before_action: set_article (or equivalent) must include :autosave in its only: list
  4. Broadcast conflicts: Never use broadcasts_refreshes on models with Tiptap -- Turbo morphing destroys editor state mid-edit. If you need real-time updates, scope broadcasts to exclude the editing user.
  5. ActionText confusion: This pattern is NOT ActionText. Content is plain markdown in text columns. Do not add has_rich_text declarations.
  6. Importmap incompatibility: Tiptap's packages are not ESM-compatible with importmap. You MUST use esbuild, vite, or another JS bundler. See references/installation.md for setup.
  7. BubbleMenu target relocation: Tiptap's BubbleMenu extension moves the DOM element outside the Stimulus controller scope, making this.bubbleMenuTarget unreachable after initialization. The controller must save a reference before calling new Editor(). This is the #1 source of "target not found" errors. See references/stimulus-controller.md.
  8. Turbo cache stale editors: Without proper turbo:before-cache handling, back-button navigation shows a broken editor that won't reinitialize. The controller must destroy the editor and restore the DOM before Turbo caches the page. See references/stimulus-controller.md.

Multiple Rich Text Fields on One Page

Each field gets its own controller instance via its own render call. The field value tells the autosave endpoint which column to update:

erb
<%= render "shared/rich_text_field",
    url: autosave_article_path(@article),
    field: "body",
    content: @article.body,
    placeholder: "Article body...",
    label: "Body" %>

<%= render "shared/rich_text_field",
    url: autosave_article_path(@article),
    field: "summary",
    content: @article.summary,
    placeholder: "Brief summary...",
    label: "Summary" %>

Each instance is fully independent -- separate editor, separate autosave, separate status indicator.

Rendering Saved Markdown

Since content is stored as markdown, you need to render it to HTML for display. Common approaches:

ruby
# Gemfile
gem "redcarpet"
# or
gem "commonmarker"
ruby
# app/helpers/markdown_helper.rb
module MarkdownHelper
  def render_markdown(text)
    return "" if text.blank?

    renderer = Redcarpet::Render::HTML.new(hard_wrap: true, filter_html: true)
    markdown = Redcarpet::Markdown.new(renderer,
      autolink: true,
      tables: true,
      fenced_code_blocks: true,
      strikethrough: true
    )
    markdown.render(text).html_safe
  end
end
erb
<%# In your show view %>
<div class="prose prose-sm max-w-none">
  <%= render_markdown(@article.body) %>
</div>

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Rails Tiptap Autosave AI skill do?

Add Tiptap rich text editing with debounced autosave to Rails models using Stimulus. Stores markdown in text columns (not ActionText). Covers installation, Stimulus controller, shared partials, Turbo cache handling, and optional change tracking.

Why use Rails Tiptap Autosave on TypingMind?

Because you install it once and use it with any model. Rails Tiptap Autosave is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Rails Tiptap Autosave in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/obie/skills/tree/main/skills/rails-tiptap-autosave. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Rails Tiptap Autosave?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Rails Tiptap Autosave?

As many as you like. As long as a model supports skills, you can use Rails Tiptap Autosave with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Rails Tiptap Autosave AI skill free?

Yes. It is published on GitHub by obie under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇