import { Controller } from "@hotwired/stimulus"
import { DirectUpload } from "@rails/activestorage"
export default class extends Controller {
static targets = ["input", "preview", "status"]
static values = {
class ActivityPanelController < ApplicationController
def show
@project = Project.find(params[:project_id])
@events = @project.events.order(created_at: :desc).limit(50)
latest = @events.maximum(:updated_at)
class Comment < ApplicationRecord
belongs_to :post
belongs_to :author, class_name: 'User'
# Automatically broadcast changes to all subscribers of this post
after_create_commit -> { broadcast_append_to post, target: "comments" }
class DashboardWidget < ApplicationRecord
broadcasts_refreshes
end
class PostsController < ApplicationController
def create
@post = current_user.posts.build(post_params)
if @post.save
flash[:success] = 'Post was successfully created.'
<nav class="flex gap-2">
<%= link_to 'Profile', settings_path(tab: 'profile'), data: { turbo_frame: 'tab_content' } %>
<%= link_to 'Billing', settings_path(tab: 'billing'), data: { turbo_frame: 'tab_content' } %>
</nav>
<%= turbo_frame_tag 'tab_content' do %>
class Message < ApplicationRecord
belongs_to :room
broadcasts_to ->(message) { [message.room, :messages] }, inserts_by: :prepend
end
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["field"]
connect() {
respond_to do |format|
format.turbo_stream
format.html { redirect_to projects_path, notice: 'Created.' }
end
class WizardsController < ApplicationController
before_action :load_draft
def step_1
render_step(1)
end
<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",
.confirm-dialog {
border: none;
border-radius: 12px;
padding: 1.5rem;
max-width: 26rem;
box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);