Sha256: 30cd7b0a2882d21fab2f5a8d4c240d4c127d199f0e8851c6c026ec794f4b1ff2

Contents?: true

Size: 612 Bytes

Versions: 7

Compression:

Stored size: 612 Bytes

Contents

class Organization < ActiveRecord::Base
  attr_protected :created_at, :updated_at
	
	after_create  :create_party
	after_save    :save_party
	after_destroy :destroy_party
	
  has_one :party, :as => :business_party

  def create_party
    pty = Party.new
    pty.description = self.description
    pty.business_party = self
    
    pty.save
    self.save
  end
    
	def save_party
    self.party.description = self.description
    self.party.save
	end

  def destroy_party
    if self.party
	    self.party.destroy
    end
  end
 
  def to_label
    "#{description}"
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
erp_base_erp_svcs-4.0.0 app/models/organization.rb
erp_base_erp_svcs-3.1.5 app/models/organization.rb
erp_base_erp_svcs-3.1.4 app/models/organization.rb
erp_base_erp_svcs-3.1.3 app/models/organization.rb
erp_base_erp_svcs-3.1.2 app/models/organization.rb
erp_base_erp_svcs-3.1.1 app/models/organization.rb
erp_base_erp_svcs-3.1.0 app/models/organization.rb