Thank you Mike for your reply here is layout of the current tables:
3 Main tables: servers , dbs , apps [ For some reason
scaffold_resource did not like the work database/s application/s]
These 3 tables work together with the tables: app_svrs, db_apps and
db_svrs
DROP TABLE IF EXISTS prs_sarbox_development.servers;
CREATE TABLE prs_sarbox_development.servers (
id int(11) NOT NULL auto_increment,
name varchar(255) default NULL,
cat varchar(255) default NULL,
net_face int(11) default NULL,
ids int(11) default NULL,
mon_man int(11) default NULL,
mon_aut int(11) default NULL,
int_ip varchar(255) default NULL,
ext_ip varchar(255) default NULL,
desc varchar(255) default NULL,
bu_media varchar(255) default NULL,
bu_method varchar(255) default NULL,
bu_data_freq varchar(255) default NULL,
os_vendor varchar(255) default NULL,
os varchar(255) default NULL,
os_version varchar(255) default NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS prs_sarbox_development.dbs;
CREATE TABLE prs_sarbox_development.dbs (
id int(11) NOT NULL auto_increment,
name varchar(255) default NULL,
cat varchar(255) default NULL,
description varchar(255) default NULL,
mon_man int(11) default NULL,
mon_auto int(11) default NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS prs_sarbox_development.apps;
CREATE TABLE prs_sarbox_development.apps (
id int(11) NOT NULL auto_increment,
name varchar(255) default NULL,
fsa int(11) default NULL,
fsa_logic varchar(255) default NULL,
description varchar(255) default NULL,
bu_data varchar(255) default NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS prs_sarbox_development.app_svrs;
CREATE TABLE prs_sarbox_development.app_svrs (
id int(11) NOT NULL auto_increment,
server_id int(11) default NULL,
app_id int(11) default NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS prs_sarbox_development.db_apps;
CREATE TABLE prs_sarbox_development.db_apps (
id int(11) NOT NULL auto_increment,
db_id int(11) default NULL,
app_id int(11) default NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS prs_sarbox_development.db_svrs;
CREATE TABLE prs_sarbox_development.db_svrs (
id int(11) NOT NULL auto_increment,
db_id int(11) default NULL,
server_id int(11) default NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
When I try to open the URL:
http://192.168.2.148:3000/db_apps
I got the list of the content of the DB.
Db App
15 1 Show Edit Destroy
11 14 Show Edit Destroy
22 23 Show Edit Destroy
4 17 Show Edit Destroy
4 21 Show Edit Destroy
2 17 Show Edit Destroy
2 21 Show Edit Destroy
2 5 Show Edit Destroy
2 19 Show Edit Destroy
2 20 Show Edit Destroy
I would like to see instead of the ID of the DB or APP the Name that
belongs to that Database of the Name of the Application from the DBs
and Apps tables repectively. I might be missing something, when I
create the migration run the rake db:migrate then later edit the model
as follow:
app Model:
####################
class App < ActiveRecord::Base
has_many :servers, :through => :app_svrs
has_many :dbs, :through => :db_apps
end
app_svr Model:
####################
class AppSvr < ActiveRecord::Base
belongs_to :app
belongs_to :server
end
db Model:
####################
class Db < ActiveRecord::Base
has_many :apps, :through => :db_apps
has_many :servers, :through => :db_servers
end
db_app Model:
####################
class DbApp < ActiveRecord::Base
belongs_to :db
belongs_to :app
end
db_svr Model:
####################
class DbSvr < ActiveRecord::Base
belongs_to :db
belongs_to :server
end
server Model:
####################
class Server < ActiveRecord::Base
has_many :apps, :through => :app_svrs
has_many :dbs, :through => :db_svrs
end
Also for Edit and Add, I would like to have a Select to limit only
those values from the current values in the Database to avoid typo
errors. and what I have is an textfield instead of a select box for
the New or Edit forms.
New db_app
Db <input type = text… => Like to have a Select from the DB…
App <input type = text…
Back
Thanks in advance for your help.