Class: Spree::Base
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Spree::Base
- Includes:
- Core::Permalinks, RansackableAttributes
- Defined in:
- app/models/spree/base.rb
Direct Known Subclasses
Solidus::Migrations::PromotionWithCodeHandlers::PromotionCode, Address, Adjustment, AdjustmentReason, Asset, Calculator, Carton, Classification, Country, CustomerReturn, InventoryUnit, LegacyUser, LineItem, LineItemAction, LogEntry, OptionType, OptionValue, OptionValuesVariant, Order, OrderMutex, OrderPromotion, Payment, PaymentCaptureEvent, PaymentMethod, PaymentSource, Preference, Price, Product, ProductOptionType, ProductPromotionRule, ProductProperty, Promotion, PromotionAction, PromotionCategory, PromotionCode, PromotionCodeBatch, PromotionRule, PromotionRuleRole, PromotionRuleStore, PromotionRuleTaxon, PromotionRuleUser, Property, Refund, RefundReason, Reimbursement, Reimbursement::Credit, ReimbursementType, ReturnAuthorization, ReturnItem, ReturnReason, Role, RoleUser, Shipment, ShippingCategory, ShippingMethod, ShippingMethodCategory, ShippingMethodStockLocation, ShippingMethodZone, ShippingRate, ShippingRateTax, State, StateChange, StockItem, StockLocation, StockMovement, Store, StoreCreditCategory, StoreCreditEvent, StoreCreditReason, StoreCreditType, StorePaymentMethod, StoreShippingMethod, TaxCategory, TaxRate, TaxRateTaxCategory, Taxon, Taxonomy, UnitCancel, UserAddress, UserStockLocation, Variant, VariantPropertyRule, VariantPropertyRuleCondition, VariantPropertyRuleValue, WalletPaymentSource, Zone, ZoneMember
Class Method Summary collapse
-
.display_includes ⇒ Object
Provides a scope that should be included any time products are fetched with the intention of displaying to the user.
- .page(num) ⇒ Object
- .preference(*args) ⇒ Object
Instance Method Summary collapse
Methods included from Core::Permalinks
#generate_permalink, #save_permalink
Class Method Details
.display_includes ⇒ Object
Provides a scope that should be included any time products are fetched with the intention of displaying to the user.
Allows individual stores to include any active record scopes or joins when products are displayed.
67 68 69 |
# File 'app/models/spree/base.rb', line 67 def self.display_includes where(nil) end |
.page(num) ⇒ Object
51 52 53 54 55 56 57 |
# File 'app/models/spree/base.rb', line 51 def self.page(num) Spree::Deprecation.warn \ "Redefining Spree::Base.page for a different kaminari page name is better done inside " \ "your own app. This will be removed from future versions of solidus." send Kaminari.config.page_method_name, num end |
.preference(*args) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/models/spree/base.rb', line 9 def self.preference(*args) Spree::Deprecation.warn <<~WARN #{name} has a `preferences` column, but does not explicitly (de)serialize this column. In order to make #{name} work with future versions of Solidus (and Rails), please add the following line to your class: ``` class #{name} include Spree::Preferences::Persistable ... end ``` WARN include Spree::Preferences::Persistable preference(*args) end |
Instance Method Details
#preferences ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/models/spree/base.rb', line 25 def preferences value = read_attribute(:preferences) if !value.is_a?(Hash) Spree::Deprecation.warn <<~WARN #{self.class.name} has a `preferences` column, but does not explicitly (de)serialize this column. In order to make #{self.class.name} work with future versions of Solidus (and Rails), please add the following lines to your class: ``` class #{self.class.name} include Spree::Preferences::Persistable ... end ``` WARN self.class.include Spree::Preferences::Persistable ActiveRecord::Type::Serialized.new( ActiveRecord::Type::Text.new, ActiveRecord::Coders::YAMLColumn.new(:preferences, Hash) ).deserialize(value) else value end end |