class DashboardMetrics
include ActiveModel::Model
attr_reader :account
def initialize(account)
class CommentsController < ApplicationController
before_action :set_post
def new
@comment = @post.comments.build
end
<%= link_to 'Newest', posts_path(sort: 'new'), data: { turbo_frame: 'results', turbo_action: 'replace' } %>
<%= link_to 'Popular', posts_path(sort: 'popular'), data: { turbo_frame: 'results', turbo_action: 'replace' } %>
class ImportRun < ApplicationRecord
enum status: { pending: 0, running: 1, completed: 2, failed: 3 }
def percent
return 0 if total.to_i.zero?
[(processed.to_f / total * 100).round, 100].min
class LikesController < ApplicationController
before_action :set_post
def create
@like = current_user.likes.create!(post: @post)
respond(liked: true)
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["field", "status"]
static values = {
key: String,
<?php
use App\Models\Conversation;
use App\Models\User;
use Illuminate\Support\Facades\Broadcast;
require 'sinatra'
require 'json'
require_relative 'book'
require_relative 'helpers'
set :books, {
<!DOCTYPE html>
<html>
<head>
<title><%= content_for(:title) || "App" %></title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
import { Turbo } from "@hotwired/turbo-rails"
Turbo.StreamActions.redirect = function () {
const url = this.getAttribute("url")
if (!url) return
<!DOCTYPE html>
<html>
<head>
<title><%= content_for(:title) || "App" %></title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["input", "frame"]
static values = { url: String, delay: { type: Number, default: 300 }, min: { type: Number, default: 2 } }