class GedClient < ActiveRecord::Base
set_table_name "D_GED_CLIENT"
set_primary_key "client_id"
def client_id
read_attribute("client_id")
end
def client_id=(value)
write_attributes(self.client_id,value)
end
def name
self.client_name
end
has_many :ged_client_mappings,:foreign_key => "client_id"
end
class GedClientMapping < ActiveRecord::Base
set_table_name "D_GED_CLIENTMAPPING"
belongs_to :ged_client,
:class_name => "GedClient",
:foreign_key => "client_id"
end
Yes I know too much code for one rails model, but legacy does not follow our lovely conventions.
At the begginig doing:
>> a = GedClient.find(1001).ged_client_mappings
=> []
#which would sql in to
SELECT * FROM D_GED_CLIENTMAPPING WHERE (D_GED_CLIENTMAPPING.client_id = null)
I found that I set_primary_key in upper case which would loose the data for client id ufter lowering case for primary key. Start to fire.