Apartment.configure do |config|
config.excluded_models = %w[Tenant User]
config.tenant_names = -> { Tenant.pluck(:schema_name) }
config.use_schemas = true
end
class AddUniqueIndexToInventorySnapshots < ActiveRecord::Migration[7.1]
disable_ddl_transaction!
def change
add_index :inventory_snapshots,
[:warehouse_id, :sku],
<body>
<%= render 'shared/navbar' %>
<main class="mx-auto max-w-5xl p-6">
<%= yield %>
</main>
<h1><%= @post.title %></h1>
<p><%= @post.author_name %></p>
<%# Only sanitized rich text should be rendered as HTML %>
<div class="prose"><%= sanitize(@post.body_html, tags: %w[p a ul ol li strong em code], attributes: %w[href]) %></div>
module CursorPagination
extend ActiveSupport::Concern
private
def paginate_with_cursor(scope, per_page: 20)
class AdminController < ApplicationController
before_action :authenticate_admin!
before_action :disable_turbo_cache, only: %i[dashboard moderation_queue]
helper_method :turbo_cache_control_tag
class Article < ApplicationRecord
scope :ranked, -> { order(score: :desc, id: :desc) }
scope :after_cursor, ->(cursor) do
return all if cursor.nil?
class AddIndexesToPosts < ActiveRecord::Migration[6.1]
def change
add_index :posts, :author_id
add_index :posts, :published_at
add_index :posts, [:author_id, :published_at]
add_index :posts, :created_at, order: { created_at: :desc }
-- Product.active.touch_all(:cache_synced_at) for catalog 42
UPDATE "products"
SET "updated_at" = '2024-05-01 12:00:00.123456',
"cache_synced_at" = '2024-05-01 12:00:00.123456'
WHERE "products"."catalog_id" = 42
AND "products"."status" = 'active';
module KeysetPageable
extend ActiveSupport::Concern
included do
scope :keyset_page, ->(cursor: nil, per: 20) do
per = per.to_i.clamp(1, 100)
class Document < ApplicationRecord
belongs_to :account
validates :source_url, presence: true
before_save :normalize_checksum
class Order < ApplicationRecord
belongs_to :customer
scope :for_export, -> {
select(:id, :reference, :total_cents, :currency, :created_at, :customer_id)
.where.not(exported_at: nil)