Class: ApplicationRecord

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Models::AfterCommittable, Models::DragonflyAccessor, Models::EventPublishable, Schedulable
Defined in:
app/models/application_record.rb

Overview

Abstract base class for every ActiveRecord model in Heatwave.

Mixes in Models::DragonflyAccessor so any model can declare Dragonfly
image accessors, Models::EventPublishable so models can publish
domain events to the in-process pub/sub bus (app/subscribers),
Models::AfterCommittable so any instance can use the natural
obj.after_commit { … } form (forwards to Rails 7.2's
ActiveRecord.after_all_transactions_commit), and Schedulable so any
model can declare acts_as_schedulable. Also opens up Ransack
search/sort to all columns and associations by default — keep an eye on
this when exposing new models to CRM search forms.

Direct Known Subclasses

Account, Activity, ActivityAgenda, ActivityChainType, ActivityResultType, ActivityType, ActivityTypeAssignmentQueue, ActivityTypeRule, AdditionalCallCredit, Address, Agreement, AgreementParticipant, AiUsageLog, AmazonAPlusContent, AmazonBrowseNode, AmazonCatalogItemFlag, AmazonCompetitor, AmazonMarketplace, AmazonSchema, AmazonTransparencyCode, AmazonVariation, Analytic::BudgetDimension, Analytic::BudgetFact, Analytic::DateTimeDimension, Analytic::ItemDemandFact, Analytic::ItemDimension, Analytic::ItemSoldFact, Analytic::OrdersSoldFact, Analytic::ReportGroupingDimension, Analytic::SalesRepDimension, AnalyticsSqlAuditLog, ApiAuthentication, ApiConsumer, ApplicationViewRecord, Appraisal, AreaCode, Article, ArticlePage, ArticleRevision, AssignmentQueue, AssistantBrainEntry, AssistantConversation, AssistantConversationShare, AssistantMessage, AssistantToolCall, AssortmentInstruction, Authentication, AverageMonthlyTemperature, Bank, BankAccount, BankBalanceStatement, Brand, Budget, BudgetGroup, BudgetRule, BusinessUnit, BuyingGroup, CallBlock, CallLog, CallLogEvent, CallRailData, CallRecord, Campaign, CampaignAction, CampaignDelivery, CanadianTireStoreAddress, Carrier, CarrierPickup, Catalog, CatalogItem, CatalogItemRetailerProbe, Ceiling, CeilingInsulationType, CeilingType, Certification, Charity, Check, City, CliftonStrength, CommissionRate, CommissionStructure, CommissionStructureEntry, CommissionTier, Communication, CommunicationRecipient, CommunicationRecipientEmailLink, Company, CompanyHoliday, ContactForm, ContactPoint, ContentEmbedding, ContentLink, Country, Coupon, CouponSerialNumber, Course, CourseCategory, CourseEnrollment, CourseExam, CreditApplication, CreditCardVault, CreditMemo, CspReport, CustomerDropEvent, CustomerFilter, CustomerRecord, CycleCount, CycleCountItem, DataDictionary, DataDictionarySet, DataImport, DataImportCell, DataImportColumn, DataImportRow, Delivery, DesignToolFixture, DigitalAsset, DigitalAssetProductLine, DigitalAssetsDuplicate, Discount, DoNotCall, Door, DoorCoreType, DoorFrameType, DoorInsulationType, DoorType, DownloadToken, EdiCommunicationLog, EdiDocument, ElementPoleAssignment, EmailLink, EmailPreference, EmailTemplate, EmbeddedAsset, EmployeeEvent, EmployeeEventsEmailSetting, EmployeeGoal, EmployeePhoneStatus, EmployeePhoneStatusChange, EmployeeRecord, EmployeeReview, EmployeeSurveyEnrollment, EmployeeTimeOff, EmployeeWorkSchedule, Event, EventAuthor, ExchangeRate, ExclusiveItemGroup, ExportedCatalogItem, ExportedCatalogItemImage, ExportedCatalogItemPacket, ExportedCatalogItemPacketAttribute, ExportedCatalogItemPacketImageAttribute, ExteriorWall, ExteriorWallInsulationType, ExteriorWallType, Facet, FacetsProductCategories, FacetsProductLines, Feed, FeedHistory, FloorPlanDisplay, FloorPlanDisplayDigitalAsset, FloorType, FraudReport, FreightEvent, GeneratedImage, GeneratedPdf, GoogleFeed, HarmonizationCode, HeatingElementProductLineOption, HistoricalOpenActivity, IdentificationNumber, ImageDuplicatePair, ImageProfile, InstalledItem, InventoryCommit, Invoice, IqAccessoryFilter, ItAsset, Item, ItemDemandForecast, ItemDemandForecastAddition, ItemLedgerEntry, ItemProductLine, ItemRelation, Kpi, LandedCost, LedgerAccount, LedgerBeginningBalance, LedgerClosingPeriod, LedgerCompanyAccount, LedgerEntry, LedgerProject, LedgerTransaction, LegacyActivityResult, LiabilityInsurance, LineDiscount, LineItem, LinkCheck, ListingIssue, LiveEvent, LlmModel, LocatorBlackListParty, LocatorRecord, LocatorWhiteListParty, LoginActivity, MailActivity, Mailing, Manifest, MaterialAlert, MaterialAlertItem, MessagingLog, NotificationChannel, OauthCredential, OnlineOfflineUser, Opportunity, OpportunityParticipant, Order, OrderTransaction, OutgoingPayment, OutgoingPaymentItem, Packaging, Packing, Party, PartyResearchFinding, PartyResearchRun, PartyTopic, Payment, PostComment, PostalCode, PostalCodeStatistic, Praise, PriceThreshold, PrintProfile, Printer, Privacy::DeletionRequest, ProductCategory, ProductFilter, ProductLine, ProductSpecification, ProductTaxCode, Profile, PublicationItem, PurchaseOrder, PurchaseOrderItem, PurchaseOrderShipment, QeAccessStatistic, QeDataStatistic, QueueCallLog, QuickEstimator, Quote, Receipt, ReceiptDetail, RedactorDragonfly::Attach, RelatedImage, ReservedSerialNumber, ResourceTaxRate, Review, ReviewsIo, ReviewsIoImage, ReviewsIoVideo, RewardAllocation, RhcParamSet, Rma, RmaItem, RmaReasonCode, Role, RoomPlan, RoomPlanFixture, RoomType, SalesCommission, SalesCommissionNetBase, SalesCommissionNetBaseDetail, SalesForecast, SalesGoal, SalesRepQueue, SalesRepQueueEntry, SalesRepWeight, Schedule, SchedulerBooking, SchedulerBookingPage, SchedulerBookingQuestion, SchedulerHost, SchedulerProfile, Search, SearchResult, SeoBatchItem, SeoBatchJob, SeoPageKeyword, SerialNumber, ServiceJob, Shipment, ShipmentContent, ShipmentEvent, ShipmentItem, ShipmentReceipt, ShipmentReceiptItem, ShippingAccountNumber, ShippingCost, ShippingOption, Showcase, ShowcaseDigitalAsset, ShowcaseFaq, ShowcaseLegacy, ShowcaseRoomLegacy, SiteMap, SiteMapDataPoint, SiteMapLink, SiteMapPathHistory, SiteMapRecommendation, Skylight, SkylightFrameType, SkylightGlassType, SkylightInsulationType, SmsBlock, SmsMessage, Source, SpeedeeDasZip, SpeedeeManifest, SpeedeeManifestShipment, SpeedeeRate, SpeedeeService, SpeedeeZone, Spiff, SpiffEnrollment, SpiffReward, SpiffRewardThreshold, SqlRepo, StandaloneDelivery, State, StatementOfAccount, StatisticsByZip, StorageLocation, Store, StoreItem, StoreItemAudit, StoreTransfer, StrengthTheme, SubFloorType, Subscriber, SubscriberList, SupplierItem, SupplierItemPrice, SupportCase, SupportCaseParticipant, Survey, SurveyEnrollment, Tag, Tagging, TaxExemption, TaxRate, Thumb, TimeOffBalance, TimeOffBlockedDay, TimeOffPolicy, TimeOffPolicyAssignment, TimeOffRequest, TimeOffRequestDate, TimeOffType, Topic, TopicCategory, TopicExam, TopicResponse, TradeShow, TranslationKey, TranslationKeyResource, TranslationText, UnderFloor, UnderFloorInsulationType, UnderFloorType, Upload, UpsIncorrectV1471aChargeData, UpsV1471aInvoiceData, UpscaleProposal, VariableCost, VideoChapter, Visit, VisitEvent, Voltage, Vote, Voucher, VoucherItem, WarehousePackage, WayfairSchema, WebhookEvent, WebhookLog, Window, WindowFrameType, WindowGlassType, WindowInsulationType, WindowType, WorkSchedule, WorkScheduleDay, XrateAverage, Zone

Constant Summary

Constants included from Schedulable

Schedulable::SIMPLE_FORM_OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Schedulable

config

Methods included from Models::AfterCommittable

#after_commit

Methods included from Models::EventPublishable

#publish_event

Class Method Details

.ransackable_associations(_auth_object = nil) ⇒ Object

ransackable_associations by default returns the names
of all associations as an array of strings.
For overriding with a whitelist array of strings.



37
38
39
# File 'app/models/application_record.rb', line 37

def self.ransackable_associations(_auth_object = nil)
  reflect_on_all_associations.map { |a| a.name.to_s }
end

.ransackable_attributes(_auth_object = nil) ⇒ Object

ransackable_attributes by default returns all column names
and any defined ransackers as an array of strings.
For overriding with a whitelist array of strings.



29
30
31
# File 'app/models/application_record.rb', line 29

def self.ransackable_attributes(_auth_object = nil)
  column_names + _ransackers.keys
end

.ransackable_scopes(_auth_object = nil) ⇒ Object

ransackable_scopes by default returns an empty array
i.e. no class methods/scopes are authorized.
For overriding with a whitelist array of symbols.



53
54
55
# File 'app/models/application_record.rb', line 53

def self.ransackable_scopes(_auth_object = nil)
  []
end

.ransortable_attributes(auth_object = nil) ⇒ Object

ransortable_attributes by default returns the names
of all attributes available for sorting as an array of strings.
For overriding with a whitelist array of strings.



45
46
47
# File 'app/models/application_record.rb', line 45

def self.ransortable_attributes(auth_object = nil)
  ransackable_attributes(auth_object)
end

Instance Method Details

#to_relationObject



57
58
59
# File 'app/models/application_record.rb', line 57

def to_relation
  self.class.where(id: id)
end