module EmailNormalization
extend ActiveSupport::Concern
included do
attr_accessor :soft_warnings
module Paginatable
extend ActiveSupport::Concern
MAX_PER_PAGE = 100
DEFAULT_PER_PAGE = 25
module LayoutlessTurboFrame
extend ActiveSupport::Concern
included do
layout :layout_for_turbo
end
# Simple mixin
module Loggable
def log(message)
puts "[#{Time.now}] #{self.class.name}: #{message}"
end
end
module ExistenceChecks
extend ActiveSupport::Concern
class_methods do
def has_any?(conditions = {})
relation = conditions.present? ? where(conditions) : all
module ConditionalGet
extend ActiveSupport::Concern
private
def render_conditional(resource, extra: nil)
class CacheNamespace
attr_reader :name
def initialize(name, store: Rails.cache)
@name = name.to_s
@store = store
module Paginatable
extend ActiveSupport::Concern
included do
before_action :set_pagination_params, only: [:index]
end
module DangerousAction
extend ActiveSupport::Concern
FRESH_WINDOW = 10.minutes
class ConfirmationMismatch < StandardError; end
require "loofah"
class HtmlSanitizer
ALLOWED_TAGS = %w[p br a strong em ul ol li blockquote code pre h2 h3].freeze
ALLOWED_ATTRS = %w[href title].freeze
SAFE_SCHEMES = %w[http https mailto].freeze
module Cacheable
extend ActiveSupport::Concern
def cache_query(prefix, scope, expires_in: 15.minutes)
key = [prefix, cache_version_token(scope)].join("/")
class CreateAuditLogs < ActiveRecord::Migration[7.1]
def change
create_table :audit_logs do |t|
t.references :auditable, polymorphic: true, null: false
t.references :user, null: true, foreign_key: true
t.string :action, null: false