class SessionsController < ApplicationController
def new
@user = User.new
end
def create
class DocumentsController < ApplicationController
before_action :set_document, only: :destroy
def destroy
@document.discard!
<%= tag.div id: dom_id(comment), class: "comment", data: { controller: "comment" } do %>
<div class="comment__body">
<%= comment.body %>
</div>
<footer class="comment__meta">
<%= turbo_stream_from :comments %>
<section class="comments">
<h2>Discussion</h2>
<%= turbo_frame_tag "new_comment" do %>
<%# Append is also broadcast from the model; this response scrolls the author's view %>
<%= turbo_stream.append "messages" do %>
<%= render partial: "messages/message", locals: { message: @message } %>
<% end %>
<turbo-stream action="scroll_to" target="<%= dom_id(@message) %>" behavior="smooth" block="end">
import { Controller } from "@hotwired/stimulus"
import consumer from "../channels/consumer"
export default class extends Controller {
static values = { roomId: Number }
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["dialog", "message"]
connect() {
<h1>Products</h1>
<%= form_with url: products_path, method: :get,
data: { turbo_frame: "products_list", turbo_action: "advance" } do |f| %>
<div class="filters">
<%= f.text_field :q, value: params[:q], placeholder: "Search products" %>
class ProductsController < ApplicationController
def index
@products = Product
.includes(:category)
.order(created_at: :desc)
.page(params[:page])
<%# renders a lazy placeholder; real content arrives when scrolled into view %>
<div class="panel-card">
<h3 class="panel-card__title"><%= title %></h3>
<%= turbo_frame_tag dom_id(panel, :frame),
class: "panel-card__body",
<%= turbo_frame_tag dom_id(flag) do %>
<tr class="flag-row">
<td class="flag-name"><%= flag.name %></td>
<td class="flag-env"><%= flag.environment %></td>
<td class="flag-state">
<span class="badge badge--<%= flag.enabled? ? 'on' : 'off' %>">
<div class="layout" data-controller="sidebar">
<aside class="sidebar">
<%= render "shared/sidebar", active: params[:controller] %>
</aside>
<main class="content-area">