import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["field"]
connect() {
class CommentsController < ApplicationController
before_action :set_post
def create
@comment = @post.comments.build(comment_params)
class WizardsController < ApplicationController
before_action :load_draft
def step_1
render_step(1)
end
class TypingPresence
EXPIRE_AFTER = 6 # seconds
def initialize(room, redis: Redis.current)
@room = room
@redis = redis
class CreateIdempotencyKeys < ActiveRecord::Migration[7.1]
def change
create_table :idempotency_keys do |t|
t.string :key, null: false
t.string :request_path, null: false
t.datetime :locked_at
module Middleware
class RequestTimer
def initialize(app)
@app = app
end
module ConnectionHealth
extend ActiveSupport::Concern
def with_fresh_connection
conn = ActiveRecord::Base.connection
conn.verify! # pings and reconnects if the socket is dead
<article class="post">
<h1><%= @post.title %></h1>
<%= simple_format @post.body %>
<!-- Lazy load comments when scrolled into view -->
<%= turbo_frame_tag "post_#{@post.id}_comments",
class Order < ApplicationRecord
has_many :line_items, dependent: :destroy, inverse_of: :order
accepts_nested_attributes_for :line_items,
reject_if: :all_blank,
allow_destroy: true
class Cart < ApplicationRecord
TTL = 30.minutes
has_many :line_items, dependent: :destroy
enum status: { active: 0, expired: 1, checked_out: 2 }
.confirm-dialog {
border: none;
border-radius: 12px;
padding: 1.5rem;
max-width: 26rem;
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
module Keysettable
extend ActiveSupport::Concern
included do
scope :keyset_page, ->(after: nil, limit: 20) do
relation = order(created_at: :asc, id: :asc).limit(limit + 1)