Sha256: bc929a29e88cf59b4d05bb82a43f3e59becfbbe34443813f9c92ebb9d74a8953

Contents?: true

Size: 769 Bytes

Versions: 2

Compression:

Stored size: 769 Bytes

Contents

class ShopCustomer < User
  
  default_scope where(:all, :conditions => { :access => 'shop' })
  
  has_many  :orders,        :class_name => 'ShopOrder'
  has_many  :addressables,  :class_name => 'ShopAddressable', :as => :addresser
  has_many  :billings,      :through => :addressables, :source => :address, :source_type => 'ShopAddressBilling',   :uniq => true
  has_many  :shippings,     :through => :addressables, :source => :address, :source_type => 'ShopAddressShipping',  :uniq => true
  
  accepts_nested_attributes_for :orders, :allow_destroy => true
  
  before_save :set_access
  
  def first_name
    self.name.split(' ')[0]
  end
  
  def last_name
    self.name.split(' ')[1]
  end
  
  private
    def set_access
      self.access = 'shop'
    end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
radiant-shop-extension-0.9.3 app/models/shop_customer.rb
radiant-shop-extension-0.9.2 app/models/shop_customer.rb