class Api::BaseController < ActionController::API
rescue_from Devise::MissingWarden do
head :unauthorized
end
end
// math.js - Named exports
export const PI = 3.14159;
export const E = 2.71828;
export function add(a, b) {
return a + b;
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["input", "results"]
static outlets = ["results-list"]
static values = {
<?php
namespace App\Events;
use App\Models\Message;
use App\Models\User;
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint'],
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:react-hooks/recommended', 'prettier']
};
const CACHE = 'static-v1';
self.addEventListener('install', (event) => {
event.waitUntil(caches.open(CACHE));
self.skipWaiting();
});
<div id="draft_status" class="text-sm text-gray-500"></div>
<%= form_with model: @draft,
url: draft_path(@draft),
method: :patch,
data: { controller: 'autosave', turbo_stream: true } do |f| %>
<div data-controller="nested-fields">
<template data-nested-fields-target="template">
<%= form.fields_for :links, Link.new, child_index: 'NEW_RECORD' do |lf| %>
<div class="flex gap-2">
<%= lf.text_field :url, class: 'flex-1 rounded border p-2' %>
<%= lf.hidden_field :_destroy, value: '0', data: { nested_fields_target: 'destroy' } %>
web: bin/rails server
css: bin/rails tailwindcss:watch
// service-worker.js
const CACHE_NAME = 'my-pwa-cache-v1';
const urlsToCache = [
'/',
'/index.html',
<%= turbo_stream.append 'messages' do %>
<%= render @message %>
<% end %>
<turbo-stream action="scroll_into_view" target="<%= dom_id(@message) %>"></turbo-stream>
// Creating elements
const div = document.createElement('div');
div.id = 'container';
div.className = 'box rounded';
div.textContent = 'Hello World';