Sha256: 3f68aabe18f91f3d5bdb6a1c678be506a69b7ef14e1a3d9f7c4518296d0d014d

Contents?: true

Size: 865 Bytes

Versions: 2

Compression:

Stored size: 865 Bytes

Contents

module Spree
  class Affiliate < Spree::Base
    has_many :referred_records
    
    validates_presence_of :name, :path

    def referred_users
      referred_records.includes(:user).collect(&:user).compact
    end

    def referred_orders
      referred_records.includes({:user => :orders}).collect{|u| u.user.orders }.flatten.compact
    end

    def referred_count
      referred_records.count
    end

    def get_layout
      return false if layout == 'false'
      layout
    end

    private

      def self.layout_options
        [
          ["No Layout", "false"],
          ["Spree Application Layout", 'spree/layouts/spree_application'],
          ["Custom Layout Path", nil]
        ]
      end

      def self.lookup_for_partial lookup_context, partial
        lookup_context.template_exists?(partial, ["spree/affiliates"], false)
      end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spree_reffiliate-2.4.1 app/models/spree/affiliate.rb
spree_reffiliate-2.3.1 app/models/spree/affiliate.rb