Class: HhPackage::PackageBenefit
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- HhPackage::PackageBenefit
- Defined in:
- app/models/hh_package/package_benefit.rb
Overview
Model: HhPackage::PackageBenefit
Purpose:
Stores extra benefit data associated with packages. These benefits represent
additional perks or exclusive offers provided to customers beyond what is
available in-store (e.g., one extra drink per person, complimentary items).
Attributes:
- description: Text describing the benefit (supports multiple locales).
- package_type, package_id: Polymorphic association to the parent package.
- created_at, updated_at: Timestamps for record tracking.
Implementation Details:
- Uses Globalize for translation of the description field.
- Polymorphic association allows linking to any package type.
- Validates presence and length of descriptions in supported locales.
- After save, triggers a background job to touch the parent package.
Edge Cases:
- Ensures descriptions are present in English and Thai.
- Limits description length to 80 characters for all locales.
- Handles deletion and updates via parent package associations.
Schema Information
Table name: hh_package_package_benefits
id :bigint not null, primary key
description :text(65535)
package_type :string(191)
created_at :datetime not null
updated_at :datetime not null
hh_package_package_benefit_id :bigint not null
package_id :bigint
Indexes
index_hh_package_package_benefits_on_package_type_and_package_id (package_type,package_id)
Constant Summary collapse
- NO_BENEFIT =
Constants
'no_benefit'.freeze
- EXTRA_BENEFIT =
'extra_benefit'.freeze
- EXCLUSIVE =
'exclusive'.freeze