Sha256: 7e64176b41129dbc8e6256e498b9942872dc5bbe1ba9cee70d6e14babe5f3821

Contents?: true

Size: 598 Bytes

Versions: 3

Compression:

Stored size: 598 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
  validates :logo, :presence => true
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
e9_vendors-0.0.3 app/models/vendor_member.rb
e9_vendors-0.0.2 app/models/vendor_member.rb
e9_vendors-0.0.1 app/models/vendor_member.rb