Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 22nd, 2012  |  syntax: None  |  size: 1.05 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. class ConstructionMachine < ActiveRecord::Base
  2.  
  3. #Start epos-db-dependencies
  4.  #-> mysql: use epos  
  5.    establish_connection "epos"
  6.  #Table name
  7.    set_table_name "construction_machine"
  8.  
  9.  #Attribut mapping
  10.    primary_key= :cmId
  11.    foreign_key_machine_type= :lmatyId
  12.    foreign_key_employee_group= :empgrpId
  13.    foreign_key_unit_type= :cmSetOutputValue_unitId
  14.    alias_attribute :output_value, :cmSetOutputValue
  15.    alias_attribute :hourly_rate, :cmHourlyRate
  16.    alias_attribute :description, :cmText
  17.  
  18. #End epos-db-dependencies
  19.  
  20. #Map attributes
  21.  set_primary_key primary_key
  22.  alias_attribute :id, primary_key
  23.  alias_attribute :unit_id, foreign_key_unit_type
  24.  alias_attribute :machine_type_id, foreign_key_machine_type
  25.  alias_attribute :employee_group_id, foreign_key_employee_group
  26.  
  27. #Relations
  28.  has_many :operation_times, :foreign_key => primary_key
  29.  belongs_to :i_machine_type, :foreign_key => foreign_key_machine_type
  30.  belongs_to :employee_group, :foreign_key => foreign_key_employee_group
  31.  belongs_to :unit, :foreign_key => foreign_key_unit_type
  32.  
  33. end