Define relationschip external database-scheme

Hi,

i want to use or external database for my rails app. The connention to
the external database(no-rais-app) works fine, but how must i define the
relationship between this tabels (if possibly no change in the table
scructure)

The external database-scheme:

CREATE TABLE bestemmingen (
bestemming_id char(3) NOT NULL default ‘’,
naam varchar(50) default NULL,
naam_en varchar(50) default NULL,
landcode char(2) default NULL,
airport_name varchar(100) default NULL,
alt_naam varchar(50) default NULL,
dist_ams decimal(6,1) default NULL,
stad_zoeknaam varchar(50) NOT NULL default ‘’,
PRIMARY KEY (bestemming_id),
KEY land_id (landcode),
KEY stad_zoeknaam (stad_zoeknaam)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT=‘Bestemming iatacode en
iso bestand’;

CREATE TABLE landen (
landcode char(2) NOT NULL default ‘’,
naam varchar(50) NOT NULL,
naam_en varchar(50) NOT NULL,
alt_naam varchar(200) NOT NULL,
landafk char(3) default NULL,
land_zoeknaam varchar(100) NOT NULL default ‘’,
PRIMARY KEY (landcode),
KEY land_zoeknaam (land_zoeknaam)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT=‘Landen opzoek tabel’;

Grtz…remco

On Thu, Mar 6, 2008 at 9:04 AM, Remco Z. wrote:

bestemming_id char(3) NOT NULL default ‘’,
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='Bestemming iatacode en
KEY land_zoeknaam (land_zoeknaam)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT=‘Landen opzoek tabel’;

(excuse my lack of Dutch :wink:

class Land < ActiveRecord::Base
set_table_name “landen”
has_many :bestemmingen, :class_name => “Bestemming” # land_id will be
guessed
end

class Bestemming < ActiveRecord::Base
set_table_name “bestemmingen”
belongs_to: :land # land_id will be guessed
end

Note: Next time try to ask directly on rails google group, you’ll get
much better answer there.
Note 2:I haven’t worked with rails for a long time, so take this as a
direction, not ready code.
Note 3:You can find all this on api.rubyonrails.com, in the part about
ActiveRecord.

Jano