class AddConstraintsToUsers < ActiveRecord::Migration[6.1]
def change
# Null constraints
change_column_null :users, :email, false
change_column_null :users, :username, false
class RevenueStat
DEFAULT_RANGE = 30.days
def initialize(account, range: DEFAULT_RANGE)
@account = account
@range = range
require "sidekiq/api"
class QueueDepthGuard
class QueueSaturated < StandardError
attr_reader :queue, :depth
<div class="search-page">
<div class="search-header mb-6">
<h1 class="text-2xl font-bold mb-4">Search Posts</h1>
<%= form_with url: posts_path,
method: :get,
# Basic Ractor usage
ractor = Ractor.new do
# This runs in parallel, isolated from main thread
result = heavy_computation
result
end
class SignupsController < ApplicationController
def new
@user = User.new
end
def create
class Comment < ApplicationRecord
belongs_to :commentable, polymorphic: true
belongs_to :author, class_name: "User"
scope :visible, -> { where(deleted_at: nil).order(:created_at) }
class Comment < ApplicationRecord
belongs_to :account
belongs_to :author, class_name: "User"
validates :body, presence: true
class ProductsController < ApplicationController
PER_PAGE = 24
def index
@page = [params[:page].to_i, 1].max
@sort = %w[name price recent].include?(params[:sort]) ? params[:sort] : "recent"
class Current < ActiveSupport::CurrentAttributes
attribute :user, :tenant, :request_id, :ip_address
def user_display
user&.email || "system"
end
module Paginatable
extend ActiveSupport::Concern
included do
before_action :set_pagination_params, only: [:index]
end
class CreatePostService
def initialize(author:, params:)
@author = author
@params = params
end