Sha256: 14bd2568aa2b99f0dde82841808f800afc1c4c01ed922968764945c385b9ff18

Contents?: true

Size: 561 Bytes

Versions: 2

Compression:

Stored size: 561 Bytes

Contents

class VendorMember < ActiveRecord::Base
  include E9Vendors::Model

  def self.add_vendor_proxy(proxy_association)
    all.each {|member| member.vendor_proxies << proxy_association.build }
  end

  has_many :vendor_proxies, :dependent => :destroy do
    def by_category
      includes(:vendor => :vendor_categories)
        .order('vendor_categories.position')
        .group_by {|vd| vd.vendor.vendor_category.name }
    end
  end
  has_many :vendors, :through => :vendor_proxies

  mount_uploader :logo, LogoUploader

  validates :name, :presence => true
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
e9_vendors-0.0.5 app/models/vendor_member.rb
e9_vendors-0.0.4 app/models/vendor_member.rb