import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["container"]
connect() {
class ProductsController < ApplicationController
def index
@products = Product
.includes(:category)
.order(created_at: :desc)
.page(params[:page])
class SubscriptionsController < ApplicationController
def new
@subscription = current_account.subscriptions.new
end
def create
<%# 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-stream action="set_title">
<template><%= "Inbox (#{@unread_count})" %></template>
</turbo-stream>
module CollectionCacheKey
extend ActiveSupport::Concern
def cache_key_for(scope)
relation = scope.respond_to?(:all) ? scope.all : scope
model = relation.klass
class PostsController < ApplicationController
def index
@posts = Post.published
.order(created_at: :desc)
.page(params[:page])
.per(20)
module LayoutlessTurboFrame
extend ActiveSupport::Concern
included do
layout :layout_for_turbo
end
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["input", "results"]
static outlets = ["results-list"]
static values = {
<div id="save_state" class="text-xs text-gray-500">Not saved yet</div>
<div id="image_preview">
<%= render 'images/preview', record: @profile %>
</div>
<%= turbo_refreshes_with method: :morph, scroll: :preserve %>
<div class="posts-index">
<div class="sticky top-0 bg-white border-b" id="search-bar">
<%= form_with url: posts_path, method: :get, data: { turbo_frame: "_top", turbo_action: "morph" } do |f| %>
<%= f.search_field :q,