Class: ApplicationRecord

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Models::AfterCommittable, Models::DragonflyAccessor, Models::EventPublishable, Models::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/audience_members),
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 Models::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, AdActionItem, AdditionalCallCredit, Address, Agreement, AgreementParticipant, AiUsageLog, AmazonAPlusContent, AmazonBrowseNode, AmazonCatalogItemFlag, AmazonCompetitor, AmazonMarketplace, AmazonSalesRankDataPoint, AmazonSchema, AmazonTransparencyCode, 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, ArticleRevisionPage, AssignmentQueue, AssistantBrainEntry, AssistantConversation, AssistantConversationShare, AssistantMessage, AssistantToolCall, AssortmentInstruction, Audience, AudienceMember, Authentication, AverageMonthlyTemperature, Bank, BankAccount, BankBalanceStatement, Brand, Budget, BudgetGroup, BudgetRule, BusinessUnit, BuyingGroup, CallBlock, CallLog, CallLogEvent, CallRailData, CallRecord, Campaign, CampaignAction, CampaignDelivery, CanadianTireStoreAddress, Carrier, CarrierPickup, Catalog, CatalogDataPoint, CatalogItem, CatalogItemRepriceReference, 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, CourseSyncBatch, CreditApplication, CreditCardVault, CreditMemo, CspReport, CustomerDropEvent, CustomerFilter, CustomerMatchAudience, CustomerOutletPurchase, CustomerRecord, CycleCount, CycleCountItem, DailyFocus::CoachingNote, 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, EmailTemplateDataPoint, EmbeddedAsset, EmployeeEvent, EmployeeEventsEmailSetting, EmployeeGoal, EmployeePhoneStatus, EmployeePhoneStatusChange, EmployeeRecord, EmployeeReview, EmployeeSurveyEnrollment, EmployeeTimeOff, EmployeeWorkSchedule, Event, EventAuthor, ExchangeRate, ExclusiveItemGroup, ExportedCatalogItem, ExportedCatalogItemImage, ExportedCatalogItemPacket, ExportedCatalogItemPacketAttribute, ExportedCatalogItemPacketImageAttribute, ExteriorWall, ExteriorWallInsulationType, ExteriorWallType, Feed, FeedHistory, FloorPlanDisplay, FloorPlanDisplayDigitalAsset, FloorPlanDisplayRoomConfiguration, FloorType, FraudReport, FreightEvent, GeneratedImage, GeneratedPdf, 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, Maintenance::LegacyAmazonVariation, Manifest, MaterialAlert, MaterialAlertItem, MessagingLog, NotificationChannel, OauthCredential, OnlineOfflineUser, Opportunity, OpportunityParticipant, Order, OrderTransaction, OutgoingPayment, OutgoingPaymentItem, Packaging, Packing, Party, PartyResearchFinding, PartyResearchRun, PartyTopic, Payment, PhoneQueueOrderChange, PhoneQueueRotation, 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, RelatedPublication, ReservedSerialNumber, ResourceTaxRate, Review, ReviewsIo, ReviewsIoImage, ReviewsIoVideo, RewardAllocation, RhcParamSet, Rma, RmaItem, RmaReasonCode, Role, RoomConfiguration, 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, SourceDataPoint, SourceReconciliation, SpeedeeManifest, SpeedeeManifestShipment, SpeedeeRate, SpeedeeService, SpeedeeZone, Spiff, SpiffEnrollment, SpiffReward, SpiffRewardThreshold, SqlRepo, StandaloneDelivery, State, StatementOfAccount, StatisticsByZip, StorageLocation, Store, StoreItem, StoreItemAudit, StoreTransfer, StrengthTheme, SubFloorType, 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, VariantGroup, VariantGroupMember, VideoChapter, Visit, VisitEvent, VisitPageDailyCount, VisitPageDailyRefresh, Voltage, Vote, Voucher, VoucherItem, WarehousePackage, Warranty, Warranty::Product, WayfairSchema, WebhookEvent, WebhookLog, Window, WindowFrameType, WindowGlassType, WindowInsulationType, WindowType, WorkSchedule, WorkScheduleDay, XrateAverage, Zone

Constant Summary

Constants included from Models::Schedulable

Models::Schedulable::SIMPLE_FORM_OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Models::Schedulable

config

Methods included from Models::AfterCommittable

#after_commit

Methods included from Models::EventPublishable

#publish_event

Class Method Details

.ransackable_associations(_auth_object = nil) ⇒ Array<String>

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

Parameters:

  • _auth_object (Object) (defaults to: nil)

    unused Ransack auth object

Returns:

  • (Array<String>)


41
42
43
# File 'app/models/application_record.rb', line 41

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

.ransackable_attributes(_auth_object = nil) ⇒ Array<String>

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.

Parameters:

  • _auth_object (Object) (defaults to: nil)

    unused Ransack auth object

Returns:

  • (Array<String>)


31
32
33
# File 'app/models/application_record.rb', line 31

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

.ransackable_scopes(_auth_object = nil) ⇒ Array<Symbol>

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

Parameters:

  • _auth_object (Object) (defaults to: nil)

    unused Ransack auth object

Returns:

  • (Array<Symbol>)


61
62
63
# File 'app/models/application_record.rb', line 61

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

.ransortable_attributes(auth_object = nil) ⇒ Array<String>

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.

Parameters:

  • auth_object (Object) (defaults to: nil)

    unused Ransack auth object

Returns:

  • (Array<String>)


51
52
53
# File 'app/models/application_record.rb', line 51

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

Instance Method Details

#to_relationActiveRecord::Relation

Returns:

  • (ActiveRecord::Relation)


66
67
68
# File 'app/models/application_record.rb', line 66

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