Repository navigation
GemStack 0.4.0
Upgrading from 0.3.x: run gemstack update (it also updates the files gemstack new wrote). Apps that
added realtime: copy frontend/lib/gemstack/realtime.ts from a fresh gemstack add realtime for
WebSockets, realtime.send, presence and the offline status — the old client keeps working over
Server-Sent Events. Validation error messages now list the failures (the errors hash is unchanged).
- Model enums:
enum :status, %w[draft published archived], default: "draft"— a string column
limited to those values, validated, accepted only with those values by the request schema, typed
"draft" | "published" | "archived"in TypeScript and OpenAPI, withProduct.statuses,draft?,
published!and chainableProduct.published(prefix:for clashes). Generators take
status:enum:draft,published,archived(migration column, theenumline, a<select>in the form).
Schemas and fields takeenum:too. - Validation errors say what failed in their message — "Validation failed: price must be greater than 0" —
not only inerrors, and generated forms show the message when an error belongs to no field in the form
(e.g.errors.add(:base, …)); before, such errors left the form without any message. - Realtime runs over WebSockets.
gemstack add realtimegives one WebSocket per browser tab on
/api/realtime(same origin; the dev gateway and kamal-proxy route it with/api), carrying
subscriptions, broadcasts, browser → server messages (realtime.send→receivein
config/channels.rb, with replies), presence (channel "rooms:*", presence: true,usePresence,
GemStack::Realtime.present_on), connection identity (identify) and replay after reconnects. The
browser client reconnects with backoff, resubscribes and de-duplicates; Origins are checked and
messages are size- and rate-limited.GemStack.broadcast, channel rules and brokers are unchanged. - Server-Sent Events are a full second transport with the same features (
receivevia POST,
presence, identity, replay).config.realtime.transports(default[:websocket, :sse]) says what the
server accepts;NEXT_PUBLIC_GEMSTACK_REALTIME(auto— the default: WebSocket, falling back to SSE when
one can't be opened —websocketorsse) what the browser uses. App code is the same either way.
useRealtimeStatus()addsoffline(the browser lost its network),realtime.transportsays which one
is in use, and presence survives a reconnect withinconfig.realtime.presence_grace(3 s). Apps on the
oldrealtime.tskeep working; copy the new client to get the rest (docs/realtime.md). GemStack::Auth.user_from(request): the signed-in user outside controllers (session cookie or API
token), e.g. for realtime'sidentify.- Background jobs work from
gemstack new: apps with a database get the jobs table,gemstack new
migrates, andgemstack devruns a worker from the first run. Jobs still run only viaperform_later. - New apps include
gem "brotli", so responses are Brotli-compressed for browsers that accept it
(gzip otherwise; compression was already on by default). - PostgreSQL is the recommended production database:
config/database.yml, the Kamal config and
gemstack doctor --productionsay how to use it (DATABASE_URL). SQLite stays the development default. - GemStack now describes itself as "a fast, modular Ruby web application framework with a Next.js frontend"
(README, gem READMEs and the gem summary on rubygems.org).