class CreateCustomerRevenueSummaries < ActiveRecord::Migration[7.0]
def change
create_view :customer_revenue_summaries, materialized: true, version: 1
add_index :customer_revenue_summaries,
:customer_id,
<div class="dashboard">
<header class="dashboard__header">
<h1>Overview</h1>
<p class="muted">Real-time metrics update as they load.</p>
</header>
class ArticlesController < ApplicationController
before_action :set_article, only: %i[edit update]
def new
@article = Article.new
end
<%= form_with model: @profile do |form| %>
<div
class="field"
data-controller="character-count"
data-character-count-max-value="280"
>
module Api
module V1
class UsersController < ApplicationController
before_action :authenticate_user!, except: [:index, :show]
before_action :set_user, only: [:show, :update, :destroy]
class Comment < ApplicationRecord
belongs_to :post
belongs_to :author, class_name: "User"
validates :body, presence: true, length: { maximum: 2_000 }
class DailySignupRollup < ApplicationRecord
validates :day, presence: true, uniqueness: true
validates :total, :verified, numericality: { greater_than_or_equal_to: 0 }
scope :for_range, ->(from, to) do
where(day: from.to_date..to.to_date).order(:day)
class ReportsController < ApplicationController
def monthly_sales
year = params.fetch(:year, Date.current.year).to_i
rows = Order.monthly_sales(year: year)
@report = MonthlySalesReport.new(rows, year: year)
class NotificationsChannel < ApplicationCable::Channel
def subscribed
stream_for current_user
end
def unsubscribed
class ApplicationPolicy
attr_reader :user, :record
def initialize(user, record)
@user = user
@record = record
class User < ApplicationRecord
has_secure_password
RESET_TOKEN_TTL = 30.minutes
def self.reset_verifier
<h1>Catalog</h1>
<%= turbo_frame_tag "products" do %>
<div class="product-grid" data-controller="frame">
<% @products.each do |product| %>
<%= render "products/card", product: product %>