import { Controller } from "@hotwired/stimulus"
import { NotificationsApi } from "notifications_api"
export default class extends Controller {
static targets = ["notification"]
static values = {
class ApplicationController < ActionController::Base
before_action :authenticate_user!
rescue_from ActionController::InvalidAuthenticityToken do
handle_unauthenticated(reason: :csrf)
end
import { Turbo } from "@hotwired/turbo-rails"
Turbo.StreamActions.redirect = function () {
const url = this.getAttribute("url")
if (!url) return
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static values = { keymap: Object }
connect() {
class ReportsController < ApplicationController
def create
@report = current_user.reports.create!(
title: report_params[:title],
status: :pending,
progress: 0
<div class="layout">
<ul class="product-list">
<% @products.each do |product| %>
<li class="product-row">
<%= link_to product.name,
product_path(product),
class LikesController < ApplicationController
before_action :set_post
def create
@like = @post.likes.find_or_create_by(user: current_user)
let installed = false;
function notify(message, level = "error") {
document.dispatchEvent(
new CustomEvent("flash:show", { detail: { message, level } })
);
class PostsController < ApplicationController
def index
@posts = Post.includes(:author)
.order(created_at: :desc)
.page(params[:page])
.per(10)
<%# private stream: turbo signs the serialized record name %>
<%= turbo_stream_from current_user %>
<section class="notifications">
<h1>Notifications</h1>
import { StreamActions } from "@hotwired/turbo"
StreamActions.flash = function () {
const container = document.getElementById("flashes")
if (!container) return
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["field"]
connect() {