Technical
Legacy Database Pices

Q?: I had a problem of sybase converting everything to int if it could not understand data type


# Set in database.yaml
numconvert: false

class Machine < ActiveRecord::Base
    set_table_name "tbl_CodeMgmt_Host" 
set_primary_key "Id" 
end

class Pool < ActiveRecord::Base
  set_table_name "tbl_CodeMgmt_Pool" 
set_primary_key "Id" 
end

the join table is

tbl_CodeMgmt_PoolHost
with columns
CodeMgmtPoolId

class Machine < ActiveRecord::Base
 has_and_belongs_to_many :pools, :join_table =>
'tbl_CodeMgmt_PoolHost', :foreign_key => 'CodeMgmtHostId',
:assocciation_foreign_key => 'CodeMgmtPoolId'
 set_table_name "tbl_CodeMgmt_Host" # must be below has_... declaration
 set_primary_key "Id" 

class Pool < ActiveRecord::Base
 has_and_belongs_to_many :machines, :join_table =>
'tbl_CodeMgmt_PoolHost', :foreign_key =>
'CodeMgmtPoolIdCodeMgmtHostId', :assocciation_foreign_key =>
'CodeMgmtHostId'
 set_table_name "tbl_CodeMgmt_Pool" # must be below has_... declaration
 set_primary_key "Id" 
end

Even if I have messed things up, :foreign_key,
:association_foreign_key and :join_table_name are the things to look
at.
has_and_belongs_to_many :machines,
:join_table => 'tbl_CodeMgmt_PoolHost',
:foreign_key => 'CodeMgmtPoolId', :assocciation_foreign_key => 'CodeMgmtHostId'