class Comment < ApplicationRecord
belongs_to :article
belongs_to :author, class_name: "User"
validates :body, presence: true, length: { maximum: 2_000 }
<div class="copy-field"
data-controller="clipboard"
data-clipboard-content-value="<%= content %>"
data-clipboard-success-value="Copied!">
<input type="text"
<%= form_with model: @profile do |form| %>
<div
class="field"
data-controller="character-count"
data-character-count-max-value="280"
>
class SignupsController < ApplicationController
def new
@user = User.new
end
def create
class PostsController < ApplicationController
def index
@posts = Post.published
.order(created_at: :desc)
.page(params[:page])
.per(20)
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["form"]
static values = { delay: { type: Number, default: 250 } }
<%# locals: item %>
<button
type="button"
class="toggle-btn"
data-controller="toggle"
data-action="click->toggle#toggle"
<h1>Products</h1>
<%= link_to "New product", new_product_path, data: { turbo_frame: "modal" }, class: "btn" %>
<table id="products">
<tbody>
class ProductsController < ApplicationController
before_action :set_product, only: %i[edit update]
def index
@products = Product.order(:name)
end
module FlashHelper
FLASH_CLASSES = {
"notice" => "flash--success",
"alert" => "flash--error",
"error" => "flash--error"
}.freeze
import axios from 'axios';
export type NormalizedErrors = {
fields: Record<string, string>;
formLevel: string | null;
};
import { z } from "zod";
export const envSchema = z.object({
VITE_API_URL: z.string().url(),
VITE_APP_NAME: z.string().min(1).default("my-app"),
VITE_ENABLE_ANALYTICS: z