Sha256: 4cc337da135233cfadeeefcdb41322ce7af36a88447ce7c0a6f6585e045019c3

Contents?: true

Size: 1.14 KB

Versions: 1

Compression:

Stored size: 1.14 KB

Contents

module Enjoy::Catalog
  module Models
    module Mongoid
      module Item
        extend ActiveSupport::Concern

        include Enjoy::HtmlField

        included do
          field :name, type: String, localize: Enjoy::Catalog.configuration.localize, default: ""

          acts_as_nested_set
          scope :sorted, -> { order_by([:lft, :asc]) }

          enjoy_cms_html_field :excerpt,   type: String, localize: Enjoy::Catalog.configuration.localize, default: ""
          enjoy_cms_html_field :content,   type: String, localize: Enjoy::Catalog.configuration.localize, default: ""

          has_and_belongs_to_many :categories, class_name: "Enjoy::Catalog::Category", inverse_of: nil

          embeds_many :item_images, cascade_callbacks: true, class_name: "Enjoy::Catalog::ItemImage"
          alias :images :item_images
          accepts_nested_attributes_for :item_images, allow_destroy: true

          has_and_belongs_to_many :related_items, :class_name => "Enjoy::Catalog::Item", :inverse_of => :related_items

          field :price,     type: Money,    default: nil, localize: Enjoy::Catalog.configuration.localize
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
enjoy_cms_catalog-0.4.0.beta3 lib/enjoy/catalog/models/mongoid/item.rb