{"slug": "redprints-advent-an-open-source-advent-calendar-app-built-with-rails-herb-and", "title": "Redprints Advent: an open source advent calendar app built with Rails, Herb, and AnyCable", "summary": "Evil Martians has open-sourced Redprints Advent, a Ruby on Rails advent calendar application built with Herb, Hotwire, and AnyCable, available on GitHub. The app, which ran in 2025 with 38 Martians posting approximately 350 replies and about as many pictures, features rich text replies via Lexxy and Action Text 8.2, Noticed-powered notifications, RubyLLM agent-based machine translation, and an Avo 4 admin panel. Evil Martians positions the release both as a ready-made app for teams and as a reference implementation that coding agents can run, test, and copy, arguing executable recipes work better than documentation files.", "body_md": "# Redprints Advent: an open source advent calendar app built with Rails, Herb, and AnyCable\n\nThe winter season is here, and it’s time to pick your advent calendar adventure. Years now at Evil Martians that choice has been Martian Advent, a team-wide space for sharing random facts and deep thoughts, struggles and wins, one bit a day. Or, everything that makes us human.\n\nToday, we’re open-sourcing the software behind it: [Redprints Advent](https://github.com/evilmartians/redprints-advent) is a Ruby on Rails application built with Herb, Hotwire, and AnyCable for our new era of AI software development. As code gets cheap, human relationships are worth even more. Grab our *Redprint* and start an advent calendar for your team or community today!\n\n[Check out Redprints Advent on GitHub](https://github.com/evilmartians/redprints-advent), or keep reading to see what’s inside and how we built it.\n\n## \n\nMartian Advent started in 2020 during the COVID-19 pandemic. We’ve been remote from day one, but we still used to meet in the offices and at offsites, usually around New Year. The pandemic put all of that on hold. To try to replace the in-person vibes, we came up with a *team advent*, a daily check-in on a new topic that helps us learn more about each other.\n\nFor the first few editions, we ran the advent on [Basecamp](https://basecamp.com) check-ins. That worked fine, but we knew we could do better. Two things made the switch possible in 2024: AI and [Inertia on Rails](https://inertia-rails.dev).\n\nOur client [StackBlitz](https://stackblitz.com) had just launched [bolt.new](https://bolt.new), and I gave creating the UI and UX for a new advent app a shot. It turned out pretty nice (yes, even way back in late 2024). Porting it to Inertia on Rails was a no-brainer, and Martian Advent 2024 was a huge success.\n\nIn 2025, we ran the same app, slightly upgraded: 38 Martians posted approximately 350 replies and about as many pictures. We’ve now decided to open source it before Christmas as part of the [Martian Redprints](https://evilmartians.com/chronicles/redprints-cfp-open-source-cfp-management-app-build-with-rails-and-inertia-js) series.\n\n### \n\nA Redprint is two things:\n\n- **A ready-made application** that needs minimal setup. Our first,[Redprints CFP](https://github.com/evilmartians/redprints-cfp) has proven its worth:[Deccan Queen on Rails](https://deccanqueenonrails.com/) ran its talk selection on it, and[Tropical on Rails](https://www.tropicalonrails.com/en) used it in 2026 and is running its 2027 CFP on it, too.\n- **A reference implementation for AI agents.*** Executable* recipes of best practices work much better than a pile of`.md` files. An agent can run, test, and copy a working app; it can only guess from a document.\n\nRedprints Advent does both of those jobs. You can run your team’s advent on it this month, and you can point your coding agent at it as an example of a modern Rails app.\n\n## \n\nThe app opens one question a day in December. Users reply, comment, react, and follow each other. Period. Okay, that was too high-level an overview. Here are some of the notable features you can find in the app and the tech behind them:\n\n- **Rich text replies** with[Lexxy](https://github.com/basecamp/lexxy) backed by Action Text 8.2 with a new[abstract ActionText::Editor](https://github.com/rails/rails/pull/51238) interface: rich formatting options, inline images, mentions.\n- **Notifications** powered by[Noticed](https://github.com/excid3/noticed) : the in-app “bell” with grouping, Slack-like reply subscriptions, daily digests, and more.\n- **Machine translations** backed by[RubyLLM](https://rubyllm.com) agents: let humans express their thoughts in their native language and machines make them accessible to everyone. The agent detects the language of every new reply, and the “Translate” button runs in the background and delivers the result live, only to the reader who asked.\n- **An admin panel** on[Avo](https://avohq.io) 4: moderators can write questions, pre-translate them, and generate covers with AI.\n- **Flexible authentication** : GitHub and Google OAuth, magic links, and invitations with different registration strategies (open, domains allowlist, or invitation-only).\n- **Live updates and statuses** : learn about new reactions, comments, or who’s reading the replies without reloading the page or losing any events during network disruptions—[AnyCable](https://anycable.io) got you covered!\n- **Image processing off Rails** with[imgproxy](https://imgproxy.net) : advent participants attach a lot of pictures, so we recommend handing image resizing over to imgproxy from day one (it’s a single configuration switch).\n\nFor minimal customization, all you need is to change `config/app.yml` (name, time zone, days, languages, registration rules) and tune `theme.css`. Want more, or don’t know where to start? Ask your agent to “set up an advent calendar”, and the `advent-setup` skill included in the repo will do the rest. It’s interactive: it asks you questions and guides you and your agent through every step of making the advent yours, from the UI design to the deployment.\n\nThe application is built with Rails 8.2 (not yet released, so we run on `main`). The primary reason for that is our choice of the frontend stack.\n\n## \n\nOur first Redprint is already an example of an Inertia on Rails application, so I picked a different frontend stack for Martian Advent v2. Which one? I’m friends with [Marco Roth](https://marcoroth.dev). I’ve watched him present progress of the Herb ecosystem throughout the year (and around the world). Going all-in on Herb and ERB was the obvious option, especially since it’s going to be part of Rails 8.2.\n\n[Herb](https://herb-tools.dev) is a toolchain for HTML+ERB templates: a parser, a linter, a formatter, a language server, browser dev tools, custom components, and more. [ReActionView](https://reactionview.dev) takes Herb and brings reactivity to the Rails view layer with client state, deferred content loading, and *targeted* HTML updates. Redprints Advent uses them wherever they fit and doesn’t hesitate to fall back to classic [Hotwire](https://hotwired.dev) options like Turbo Streams and Turbo Frames.\n\n### \n\nOptimistic UI has always been a major argument for choosing React (or other JavaScript frameworks) over HTML templates when building web UIs. You can use Stimulus to bring optimism to Hotwire apps, but it usually requires custom wiring for every use case. Herb and ReActionView give you enough **client state** to make optimistic UI a reality for HTML-driven applications with no JavaScript attached.\n\nLet’s consider reactions, for example. In the Advent app, we provide a predefined set of emojis to pick (like on GitHub). Clicking an emoji submits an HTML form; the `reactions#create` controller action handles the request and responds with the updated reactions HTML snippet (or returns the full page and lets the client replace the DOM itself). Here is the corresponding ERB template:\n\n```\n<%# locals: (reactable:, kind:, count:, mine:) -%>\n\n<div class=\"item\">\n  <%= form_with url: (mine ? reaction_path(mine) : polymorphic_path([reactable, :reactions])), method: (mine ? :delete : :post) do %>\n    <button type=\"submit\" name=\"reaction[kind]\" value=\"<%= kind %>\" aria-pressed=\"<%= mine %>\">\n      <%= render \"reactions/icon\", kind: %>\n    </button>\n  <% end %>\n  <% if count > 0 %>\n    <span class=\"count\"><%= count %></span>\n  <% end %>\n</div>\n```\n\nWe have Vanilla Rails and Hotwire behind the scenes. It works, it passes all tests. But what about the user experience? Let’s see it in action:\n\nDepending on the server load and network conditions, the gap between the action that’s expected to be immediate and the actual UI update can be too big to ignore. To eliminate this, we need some client-side *buffer*, a state that we can update right away and use for drawing UI while the request is in progress. Herb gives us such a state, and we don’t need to leave the partial template to use it.\n\nHere’s an updated snippet with Herb state attached:\n\n```\n<%# locals: (reactable:, kind:, count:, mine:) -%>\n\n<%# herb:slots client %>\n<%# herb:state (pressed_reaction: mine, reaction_count: count) %>\n\n<div class=\"item\">\n  <%= form_with url: (mine ? reaction_path(mine) : polymorphic_path([reactable, :reactions])), method: (mine ? :delete : :post) do %>\n    <button type=\"submit\" name=\"reaction[kind]\" value=\"<%= kind %>\" aria-pressed=\"<%= pressed_reaction %>\" data-reacted=\"<%= reaction_count > 0 %>\" data-herb-toggle=\"pressed_reaction\" data-herb-increment=\"reaction_count\" data-herb-by=\"<%= mine ? -1 : 1 %>\">\n      <%= render \"reactions/icon\", kind: %>\n    </button>\n  <% end %>\n  <% if reaction_count > 0 %>\n    <span class=\"count\"><%= reaction_count %></span>\n  <% end %>\n</div>\n```\n\nLook at the optimistic reactions in action:\n\nThe changes in the partial template are minimal. The `herb:state` comment declares two client state values, `pressed_reaction` and `reaction_count`, with the server-provided values as defaults. On click, `data-herb-toggle` flips the pressed state, and `data-herb-increment` changes the counter by `data-herb-by` (plus or minus one).\n\nHerb’s client runtime updates everything bound to these values, so the button and the counter change before the request completes. The controller then delivers the server-verified state as HTML, and the local and server states reconcile. Reply subscriptions and follows work the same way.\n\nAnother usage of Herb state is showing and hiding editor forms:\n\n```\n<%# locals: (reply:, editable:) -%>\n\n<%# herb:slots client %>\n<%# herb:state (editing_reply: reply.errors.any?) %>\n\n<style scoped>\n  @layer components {\n    .content:is([data-editing-reply=\"true\"] *),\n    .editor:is([data-editing-reply=\"false\"] *) {\n      display: none;\n    }\n  }\n</style>\n\n<div class=\"reply\" id=\"<%= dom_id(reply) %>\" data-editing-reply=\"<%= editing_reply %>\">\n  <% if editable %>\n    <button type=\"button\" class=\"action\" title=\"<%= t(\".edit\") %>\" data-herb-toggle=\"editing_reply\"><%= svg \"tabler/outline/pencil\" %></button>\n  <% end %>\n\n  <div class=\"content\" id=\"<%= dom_id(reply, :content) %>\">\n    <%= render \"translations/content\", record: reply %>\n  </div>\n\n  <% if editable %>\n    <div class=\"editor\">\n      <%= render \"replies/form\", reply: %>\n      <div class=\"form-actions\">\n        <button type=\"button\" class=\"button button-secondary\" data-herb-set=\"editing_reply=false\"><%= t(\"replies.form.cancel\") %></button>\n        <button type=\"submit\" class=\"button\" form=\"<%= dom_id(reply, :form) %>\"><%= t(\"replies.form.submit\") %></button>\n      </div>\n    </div>\n  <% end %>\n</div>\n```\n\nThe pencil button flips `editing_reply` with `data-herb-toggle`, and “Cancel” resets it with `data-herb-set`. The state lands in the `data-editing-reply` attribute, and two scoped CSS rules do the rest: one hides the content, the other hides the editor. When a save fails, the server renders the reply with `editing_reply` already on (`reply.errors.any?`), so the user sees the form with the errors.\n\nAs you can see, Herb takes you further than plain ERB and Hotwire without custom JavaScript, and without a server round-trip for every interaction.\n\nThat doesn’t mean we didn’t add any JavaScript. Our final reactions UI turned out to be complex (and compact), and we ended up adding a custom [Herb behavior](https://herb-tools.dev/projects/client#behaviors) to control the state.\n\nThe snippet above hints at another Herb feature we use extensively in the app—scoped styles.\n\n### \n\nHerb gives us a way to keep styles right next to HTML using [Scoped Styles](https://herb-tools.dev/language/scoped-styles). How does it work? A template keeps its CSS in a `<style scoped>` block; Herb marks the template’s elements with a `data-herb-scope-<hash>` attribute derived from the file path and narrows each selector to require it: `.toggle` becomes `.toggle[data-herb-scope-1a2b3c4d]`. A `.toggle` class in one partial never leaks into another, and the markup of nested partials doesn’t pick up the parent’s styles. (Sounds like CSS Modules, doesn’t it?)\n\nNot everything goes into scoped styles, though. The global CSS lives in `app/assets/stylesheets/`, and each file puts its rules into a cascade layer:\n\n- **`theme`** :` theme.css` with the brand knobs and`tokens.css` with the design tokens derived from them. Scoped styles use only these tokens.\n- **`vendor`** :` rich_text.css` , the Lexxy styles with their colors mapped to our tokens.\n- **`base`** : element styles in` base.css` and the form controls and buttons in`forms.css` . Forms look the same on every page, and the HTML that`form_with` and`button_to` generate doesn’t get the scope attribute anyway.\n- **`components`** : the`<style scoped>` blocks of pages and partials.\n- **`utilities`** : a few helper classes, added only when a template uses them.\n\nHerb can [deliver the scoped CSS](https://herb-tools.dev/projects/engine/visitors/scoped-style) in three ways. The default, `:inline`, leaves the block where it was written and writes it again on every render. `:hoist` registers the CSS once per page and puts it into `<head>`. `:none` drops the block (assuming it was collected during asset precompilation). We use `:hoist`: a reply renders the reaction partial six times, but its CSS appears on the page once.\n\nHoisting scoped styles required a bit of plumbing for Turbo Frames. Turbo takes only the `<turbo-frame>` element from the response and `<meta>` tags from its `<head>`; the hoisted styles (also delivered in the `<head>`) never reach the page. A small script fixes that: it catches the frame’s response and adds the styles that the page doesn’t have yet, once for each style definition:\n\n``` js\ndocument.addEventListener(\"turbo:before-frame-render\", (event) => {\n  const response = inflightResponses.get(event.target)\n  if (!response) return\n\n  inflightResponses.delete(event.target)\n\n  const render = event.detail.render\n\n  // Ensure styles are applied before we render the frame\n  event.detail.render = (prevEl, newEl) => {\n    response.responseHTML.then((html) => {\n      if (!html) return\n      const styles = new DOMParser().parseFromString(html, \"text/html\").head.querySelectorAll(\"style[data-herb-scoped-styles]\")\n\n      adoptStyles(styles)\n    }).then(() => render(prevEl, newEl))\n  }\n})\n```\n\nTurbo Streams need the same fix. Our [Herb and Turbo docs](https://github.com/evilmartians/redprints-advent/blob/master/docs/herb.md) explain how it works.\n\nThere’s no CSS framework and no build step: [import maps and Propshaft](https://github.com/rails/importmap-rails) serve the files as they are. [Bundlebun](https://github.com/yaroslav/bundlebun) gives us Bun only to run `herb-lint` in development.\n\n### \n\nSo, what are our first impressions of Herb? Well, it’s impressive! The ergonomics feel right for Rails, the tooling (like `herb-lint`) keeps the templates in shape, and the resulting UI feels like 2026 and beyond.\n\nKeep in mind that Herb and ReActionView are still young, some of the features we use (scoped styles, client state) are experimental, others we tried didn’t fit our UI/UX (so we had to fall back to Turbo). So, for most apps advanced Herb and ReActionView features are the future but not today; for enthusiasts like us the future is out there 🛸.\n\n## \n\nA Redprint is a reference for agents, so the conventions must be enforced, not only written down. An agent reads `AGENTS.md`, but it can skip or misinterpret a rule; it can’t skip a failing check. Here’s what we’ve added to our *guardbelt*.\n\n**Archspec** helps us draw the architecture boundaries. [Archspec](https://archspecrb.dev) prevents agents from processing request params in models, accessing `Current.user` deep inside the execution stack, and so on. Our configuration, `Archspec.rb`, describes the app in terms of the [layered design](https://evilmartians.com/chronicles/it-deserved-its-own-tome-layered-design-and-the-extended-rails-way): presentation, application, domain, and infrastructure.\n\n```\narchitecture :layered, layers: {\n  presentation: %w[app/controllers/**/*.rb app/helpers/**/*.rb app/avo/**/*.rb app/jobs/**/*.rb],\n  application: %w[app/agents/**/*.rb app/forms/**/*.rb app/mailers/**/*.rb app/notifiers/**/*.rb],\n  domain: %w[app/models/**/*.rb config/configs/**/*.rb],\n  infrastructure: %w[app/lib/**/*.rb]\n}\n\ndomain.cannot_call :render, :redirect_to, :params, :session, :cookies, :flash, receiver: :none\ndomain.cannot_reference_constants \"Current\"\n```\n\n**A design system that checks itself.** The less we look at the generated code, the more guardrails it needs. Agents are good at CSS and HTML but not so good at following style guides and reusing what’s already available.\n\nThis, we have a strict design system with a written contract (`config/design_system.yml` defines and describes available tokens), *layered* CSS design with `theme.css` describing the brand and `tokens.css` deriving every token from them, and a dozen **custom herb-lint rules** to enforce the style guide. For example, `style-no-literal-values` rejects `#fff`, `oklch(...)`, or `12px` in component CSS, so every value comes from a design token, and a rebrand stays a `theme.css` change.\n\nThe Design System section in [Lookbook](https://lookbook.build) shows each token with its value, purpose, and usages; that’s where a human can see the current state and decide when the contract needs to change.\n\nThe design system contract is enforced by tests, too. A spec checks that `config/design_system.yml` describes every token in `tokens.css` and every text class in `typography.css`, so no token ships without a documented purpose. Together with the lint rules, that makes a rebrand safe for an agent, not just possible.\n\nThe Herb linter is also used to validate the email stylesheet: it’s generated by an agent (spec-driven generation) and verified by the linter. Email clients don’t understand OKLCH or `rem`, so we have to convert them for `email.css`. The linter resolves each token from the theme and compares it with the inlined value to ensure they stay in sync. Sure, we could add a line to the `AGENTS.md` to “check all the inlined values in email.css” but why take the risk of non-determinism when the right tooling exists?\n\n**Lefthook consolidates all the checks in one config.** [Lefthook](https://github.com/evilmartians/lefthook) runs RuboCop and herb-lint on `pre-commit`; archspec, [Brakeman](https://brakemanscanner.org), and the Lookbook specs on `pre-push`. The same `lefthook.yml` has a third hook, `validate`, for AI agents, which reuses both lists via YAML anchors, so there’s no second list of checks to keep in sync.\n\n```\npre-commit:\n  parallel: true\n  files: \"git diff --name-only --cached --diff-filter=d\"\n  jobs: &pre_commit\n    - name: rubocop\n      glob: \"*.{rb,rake}\"\n      run: \"{bundle} rubocop --parallel --force-exclusion {files}\"\n    - name: herb_lint\n      glob: \"*.erb\"\n      run: \"{bun} herb-lint {files}\"\n\npre-push:\n  parallel: true\n  jobs: &pre_push\n    - name: archspec\n      run: \"{bundle} archspec check\"\n    # ...brakeman, lookbook\n\nvalidate:\n  parallel: true\n  # The changed and the new files\n  files: \"git diff --name-only --diff-filter=d HEAD; git ls-files --others --exclude-standard\"\n  jobs:\n    - name: pre-commit\n      group:\n        parallel: true\n        jobs: *pre_commit\n    - name: pre-push\n      group:\n        parallel: true\n        jobs: *pre_push\n```\n\nNote the `files` option of `validate`: it lists the new files, too. `--all-files` covers only the tracked ones, and an agent creates a lot of new files.\n\nA [Claude Code Stop hook](https://code.claude.com/docs/en/hooks) runs `lefthook run validate` when the agent finishes a turn. Claude Code sends the hook’s output back to the agent only when the hook exits with code 2; any other failure is shown only to the user, and the agent stops as if nothing happened. That’s why we have a custom `.claude/hooks/lefthook.sh` script (trimmed):\n\n```\n# Run once per turn: skip if the agent is already fixing the previous report\nif grep -Eq '\"stop_hook_active\"[[:space:]]*:[[:space:]]*true'; then\n  exit 0\nfi\n\n# Nothing changed, nothing to check\nif [[ -z \"$(git status --porcelain)\" ]]; then\n  exit 0\nfi\n\nif ! output=$(lefthook run validate --no-tty --colors off 2>&1); then\n  {\n    echo \"Lefthook checks failed (the \\`validate\\` hook in lefthook.yml). Fix the problems below, then finish:\"\n    echo \"$output\"\n  } >&2\n  exit 2\nfi\n```\n\n**Runtime checks catch what static analysis can’t.** Two gems from the test suite guard the data layer:\n\n- [Isolator](https://github.com/palkan/isolator) raises in tests when code does something inside a database transaction that a rollback can’t undo: sends an email, makes an HTTP call, or enqueues a job.\n- [n_plus_one_control](https://github.com/palkan/n_plus_one_control) checks that a page runs the same number of queries for one record and for many.\n\nEvery page with lists (the calendar, the question page, the notifications) has an N+1 test like this one:\n\n```\ncontext \"N+1\", :n_plus_one do\n  populate do |n|\n    n.times do\n      reply = create(:reply, question:, user: create(:user, :with_avatar))\n      create(:reaction, reactable: reply, user: create(:user, :with_avatar))\n      create(:reaction, reactable: reply, user:, kind: \"heart\")\n      create(:comment, reply:, user: create(:user, :with_avatar)).then { create(:reaction, reactable: it, user:) }\n      create(:comment, reply:, user:).then { create(:reaction, reactable: it, user: create(:user, :with_avatar)) }\n      create(:subscription, reply:, user:)\n      create(:subscription, reply:, active: false)\n    end\n  end\n\n  specify do\n    expect { get question_path(question) }.to perform_constant_number_of_queries\n  end\nend\n```\n\nA test like this guards only the data it creates. When a page starts to show a new association, the `populate` block must create it, or a new N+1 query slips through. No check can tell that a block is incomplete, so this rule lives in `AGENTS.md`.\n\nChecks and text instructions aren’t rivals. A check is strict but sees only what it was built to see. An instruction covers the rest, and a check makes sure that the agent didn’t skip the instruction. Use both.\n\n**Skills cover what checks can’t.** The app comes with [Rails Hyperdrive](https://evilmartians.com/chronicles/rails-hyperdrive-supercharged-agentic-development-for-rails), which installs skills shipped by the gems themselves. The skills are automatically synced on gem updates, so your agent always gets the up-to-date guidance. This is how we get the [layered-rails-skills](https://github.com/palkan/layered-rails-skills) and AnyCable skills (more on that below).\n\nOn top of that, the project has its own skills: `advent-setup` (already mentioned) and `advent-specs`. We want the tests your agent writes for your extensions of the Redprint to be as efficient as the ones we’ve prepared for you. So, `advent-specs` explains which layer to test, the shape of each spec type, the test tooling, and how to hunt down flaky specs.\n\n## \n\nAn advent is a shared experience, so the app had better feel alive. That means a new reply should show up without a reload, the notification bell rings on its own, and you can see who else is reading today’s answers. [AnyCable](https://anycable.io) brings the real-time part, while Turbo Streams carries the updates.\n\n### \n\nThe latest [anycable-rails](https://github.com/anycable/anycable-rails/blob/main/CHANGELOG.md) release (1.6.3) ships an agent skill with the gem. It covers installation, configuration, deployment, troubleshooting, and best practices for real-time features. With the skill, the agent set up the whole chain in one shot:\n\n- \n**Development** : a new Puma plugin (another v1.6.3 highlight) starts the AnyCable server with the app, keeps it running across Puma restarts, and stops it with Puma. No Procfile required:\n\n```\n# config/puma.rb\nplugin :anycable if ENV[\"ANYCABLE_IN_PUMA\"]\n```\n\n- \n**Tests** : system specs run against a real AnyCable server with[capybara-thruster](https://github.com/evilmartians/capybara-thruster) .\n- \n**Production** :[AnyCable Thruster](https://github.com/anycable/thruster) runs the AnyCable server next to Puma in the same container, so you don’t need to worry about installing a sidecar web service. This approach fits a private advent app very well (unless you expect thousands of users: for that it’d be better to run AnyCable in its own cluster and scale independently).\n\nThe skill also replaces the default Rails Action Cable client with AnyCable’s. Why? Because we want to benefit from AnyCable features not supported by Action Cable.\n\n### \n\nThe skill also helped shape the real-time features themselves. Instead of reinventing common real-time patterns (as an agent likely would without AnyCable), we stuck to the existing AnyCable capabilities.\n\n**Broadcasts to others**: the user who made a change already sees it in the response, so `AnyCable::Rails.broadcasting_to_others` skips the sender’s socket. No race conditions between the form request and a Turbo Stream update, no double rendering, no need to even think about how to deal with this problem. **Batched broadcasts** deliver related updates to different streams as one change, in order.\n\n**Reliable streams**: the server keeps the recent history of each stream, so a client that reconnects gets the messages it missed. For example, when a user requests a content translation, we enqueue a background job to call an LLM provider and then respond with the unique stream identifier to listen for updates. What if the background job finishes before the client subscribes to the stream? We don’t care! The client gets the message from the stream history, whether it subscribes late or re-subscribes after a reconnect.\n\n**Typing indicators** use *whispers*: client-to-client messages that Rails never sees and nothing stores. The `data-typing` Herb behavior whispers while you type a comment, and the other viewers see “Vova is typing…”. E is for engagement.\n\n**Presence indicators** show who else is looking at the calendar or browsing the replies. No server-side code required: all backed by [AnyCable Presence](https://docs.anycable.io/anycable-go/presence) and the `<turbo-cable-presence-source>` element from [@anycable/turbo-stream](https://github.com/anycable/anycable-client/tree/master/packages/turbo-stream). Yes, presence tracking fully controlled by HTML! Here is how it looks:\n\n```\n<turbo-cable-presence-source id=\"<%= id %>\" data-turbo-permanent\n  signed-stream-name=\"<%= Turbo::StreamsChannel.signed_stream_name(stream) %>\"\n  presence-id=\"<%= dom_id(current_user, :presence) %>\" ignore-self>\n  <div class=\"viewers\" id=\"<%= id %>_viewers\"></div>\n\n  <template>\n    <%= turbo_stream.append \"#{id}_viewers\" do %>\n      <span class=\"viewer\" id=\"<%= dom_id(current_user, :presence) %>\">\n        <%= render \"users/avatar\", user: current_user, size: :sm %>\n      </span>\n    <% end %>\n  </template>\n</turbo-cable-presence-source>\n```\n\nThe element joins the presence set of the stream and sends its template to the others: a Turbo Stream action that appends the user’s avatar to their list. A user who leaves disappears after the presence TTL (15 seconds by default), so a page reload doesn’t make an avatar blink.\n\n### \n\nLive reactions bring back a classic real-time problem: [personalization](https://evilmartians.com/events/the-pitfalls-of-realtime-ification). A broadcast renders a partial once, with no `current_user`, but a reaction button depends on the viewer: did *I* press it? **Herb state solves that**. The broadcast sends only the shared facts, and a custom `herb_state` stream action writes the new count into the client state of each viewer’s page:\n\n```\n<%# reactions/_live.turbo_stream.erb %>\n<%# locals: (reactable:, kind:) -%>\n\n<% reactions = reactable.reactions.where(kind:).includes(user: {avatar_attachment: :blob}) %>\n<%= turbo_stream.update dom_id(reactable, \"who_#{kind}\"), partial: \"reactions/who\", locals: {reactions:} %>\n<%= turbo_stream.herb_state dom_id(reactable, \"reaction_#{kind}\"), reaction_count: reactions.size %>\n```\n\n`reaction_count` is the same for everyone, so the server sets it. `pressed_reaction` belongs to the viewer and never leaves the browser. No per-user broadcasts, “signal and fetch” requests or JavaScript to personalize the HTML.\n\n## \n\nRedprints Advent runs on Rails 8.2 (from the main branch), Ruby 4, and Avo 4. It also runs on Bundler 4.1 and uses one of its newest features—**overrides**.\n\nHerb’s client state compiler needs Prism 2, but `ruby-lsp` declares `prism < 2.0`. Bundler 4.1 has an answer for that:\n\n```\n# Gemfile\noverride \"prism\", version: :ignore_upper\n```\n\nThe override removes the upper bound that other gems declare, and the lockfile records it in an `OVERRIDES` section. We’ll drop it when `ruby-lsp` supports Prism 2 (in our experience, it already works with Prism 2, but its gemspec plays it safe).\n\n**imgproxy, one switch away.** The Redprint is preconfigured to use [imgproxy](https://imgproxy.net) for image transformations via the [imgproxy-rails](https://github.com/imgproxy/imgproxy-rails) gem. The gem implements a custom route mode for Active Storage, so all you need is a configuration switch: every Active Storage URL switches to imgproxy, which reduces the load on your Rails server. Active advent participants tend to attach many pictures to their replies, so we recommend switching to imgproxy right away (as we do every year).\n\n**Checks for every external service.** A deploy can pass and still fail to send an email or generate an image with an LLM. The `checks:*` rake tasks test each service with one command: `checks:send_email`, `checks:cable` (a test broadcast to the AnyCable server), `checks:s3`, `checks:imgproxy`, `checks:llm:translate`, and `checks:llm:cover`. Each one prints what it uses and what it got back:\n\n```\nbin/rails \"checks:send_email[you@example.com]\"\nbin/rails checks:cable\nbin/rails \"checks:llm:translate[Hello,es]\"\n```\n\n**Lookbook previews as tests.** `bin/rails lookbook:spec` renders every [Lookbook](https://lookbook.build) preview and fails on an error. It also fails when a preview writes to the database: previews must build their records in memory. We also tried [axe](https://github.com/dequelabs/axe-core) accessibility checks for the previews, and they live in the [`spike/axe` branch](https://github.com/evilmartians/redprints-advent/tree/spike/axe). They didn’t work for us because of the tricky background (animations, blur), but they should work for a simpler design.\n\n**A Turbo Stream delivery method for Noticed.** [Noticed](https://github.com/excid3/noticed) delivers notifications to the database and by email. What about live updates? The existing Action Cable adapter speaks JSON, and we prefer Turbo Streams. So, we’ve built a custom delivery method! In our case, its only role is to bring the in-app notifications to life:\n\n```\nclass ApplicationNotifier < Noticed::Event\n  deliver_by :turbo_stream, class: \"DeliveryMethods::TurboStream\" do |config|\n    config.stream = -> { [recipient, :notifications] }\n    config.partial = \"notifications/update\"\n    config.locals = -> { {count: recipient.notification_feed.count} }\n    config.locale = -> { recipient.ui_settings.ui_locale }\n  end\nend\n```\n\nThe delivery method itself is a `broadcast_render_to` call wrapped in `I18n.with_locale`, so the bell speaks the recipient’s language, not the sender’s.\n\n**Sentry setup with LLM traces.** Our production Martian Advent uses [Sentry](https://sentry.io) for errors and performance monitoring. The Redprint ships the same configuration, ready for Rails 8.2: a small patch brings back the SQL spans that Rails 8.2 breaks (see the [sentry-ruby PR](https://github.com/getsentry/sentry-ruby/pull/3241)). The configuration also reports RubyLLM calls as Sentry [AI agent spans](https://docs.sentry.io/product/agents/). Calls inside one `RubyLLM.workflow(...)` block (new in RubyLLM 2.2) share a conversation ID, so Sentry shows them together.\n\n## \n\nA Redprint is our bet on how teams will start new apps. Not beginning with a blank `rails new` and a prompt, but from a working application whose conventions are checked on every turn. The CFP Redprint runs real conferences. Meanwhile, the app behind this one has carried 38 Martians and about 350 replies through our 2025 advent, and this December it runs on the new stack.\n\n[Explore the code](https://github.com/evilmartians/redprints-advent), deploy your own advent, and tell us what your team answers on day one!", "url": "https://wpnews.pro/news/redprints-advent-an-open-source-advent-calendar-app-built-with-rails-herb-and", "canonical_source": "https://evilmartians.com/chronicles/redprints-advent-an-open-source-advent-calendar-app-built-with-rails-herb-and-anycable", "published_at": "2026-12-03 00:00:00+00:00", "updated_at": "2026-12-03 15:16:49.618567+00:00", "lang": "en", "topics": ["developer-tools", "ai-agents", "ai-tools"], "entities": ["Evil Martians", "Redprints Advent", "Ruby on Rails", "Herb", "AnyCable", "Hotwire", "RubyLLM", "Avo"], "also_reported_by": [], "takeaway": "Evil Martians frames Redprints Advent as an executable reference implementation for coding agents, arguing a runnable, testable Rails app teaches agents better than a pile of .md files.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/redprints-advent-an-open-source-advent-calendar-app-built-with-rails-herb-and", "markdown": "https://wpnews.pro/news/redprints-advent-an-open-source-advent-calendar-app-built-with-rails-herb-and.md", "text": "https://wpnews.pro/news/redprints-advent-an-open-source-advent-calendar-app-built-with-rails-herb-and.txt", "jsonld": "https://wpnews.pro/news/redprints-advent-an-open-source-advent-calendar-app-built-with-rails-herb-and.jsonld"}}