Class: ApplicationViewRecord
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- ApplicationViewRecord
- Defined in:
- app/models/application_view_record.rb
Overview
Abstract base class for all database view models.
This class provides:
- Read replica routing - queries go to replica in production/staging
- Write protection - prevents accidental INSERT/UPDATE/DELETE
- Consistent behavior for all view models
Usage:
class ViewProductCatalog < ApplicationViewRecord
# ...
end
All 74 view models inherit from this class to ensure consistent
read replica routing and write protection.
Direct Known Subclasses
ViewAccountingTransmission, ViewActivity, ViewAmazonCatalogItem, ViewArDetail, ViewArListing, ViewBookBusinessActivity, ViewBookBusinessOrdOpp, ViewBudget, ViewCallStatistic, ViewCampaignDelivery, ViewCatalogItem, ViewCertification, ViewContact, ViewCoupon, ViewCreditApplication, ViewCreditMemo, ViewCustomer, ViewDelivery, ViewEmailTemplate, ViewEmployeeReview, ViewEstimatedLandedCost, ViewExchangeRate, ViewExpandedLineItem, ViewFinancialAccountBalance, ViewInventoryPlan, ViewInvoice, ViewItAsset, ViewItem, ViewItemCatalog, ViewItemLedgerEntry, ViewItemStat, ViewKpisTimeOnTask, ViewLeadTime, ViewLedgerEntry, ViewLineItem, ViewLineItemProfit, ViewLocatorRecord, ViewOpportunitiesFact, ViewOpportunity, ViewOpportunityConversion, ViewOrder, ViewOrdersOriginFact, ViewOutgoingPayment, ViewProductCatalog, ViewProductSpecificationValue, ViewPurchaseOrder, ViewQuote, ViewQuoteBomItem, ViewQuoteSuffix, ViewReceipt, ViewReturnedItem, ViewRma, ViewRmasFact, ViewSale, ViewSalesByCustomer, ViewSalesCommission, ViewSalesDiscount, ViewSalesFact, ViewSalesGrossByRep, ViewSalesNetBase, ViewSalesNetBaseItem, ViewSalesShipping, ViewServiceJob, ViewSiblingRetailerPrice, ViewSmartServicesSale, ViewStatementOfAccount, ViewStock, ViewSupplierItem, ViewSupportCase, ViewTechProductivity, ViewVisitsConversionFact, ViewVisitsDetailFact, ViewVisitsFact, ViewVoucher
Constant Summary
Constants included from Schedulable
Schedulable::SIMPLE_FORM_OPTIONS
Class Method Summary collapse
-
.create ⇒ Object
Override to provide better error message.
- .create! ⇒ Object
Instance Method Summary collapse
-
#readonly? ⇒ Boolean
Prevent accidental writes to views This is a safety net - PostgreSQL would reject the write anyway.
Methods inherited from ApplicationRecord
ransackable_associations, ransackable_attributes, ransackable_scopes, ransortable_attributes, #to_relation
Methods included from Schedulable
Methods included from Models::AfterCommittable
Methods included from Models::EventPublishable
Class Method Details
.create ⇒ Object
Override to provide better error message
32 33 34 |
# File 'app/models/application_view_record.rb', line 32 def self.create(*) raise ActiveRecord::ReadOnlyRecord, "#{name} is a read-only view and cannot be written to" end |
.create! ⇒ Object
36 37 38 |
# File 'app/models/application_view_record.rb', line 36 def self.create!(*) raise ActiveRecord::ReadOnlyRecord, "#{name} is a read-only view and cannot be written to" end |
Instance Method Details
#readonly? ⇒ Boolean
Prevent accidental writes to views
This is a safety net - PostgreSQL would reject the write anyway
27 28 29 |
# File 'app/models/application_view_record.rb', line 27 def readonly? true end |