Dinooz
2007-Feb-21 15:56 UTC
How to create a LOV [ List of Values in a Rails Application ]
I have 3 tables for a Sarbanes Oxley application. Servers , Databases and Applications. another set of tables for the Model: Servers_Databases, Databases_Applications and Servers_Applications. My question here is how can setup a LOV in order to let the join tables have a LOV from the Servers, Databases or Applications. How would the model be applied in has_many ... :trough .... This is really cool but a little bit confusing. Thanks in advance for your help.... ##### ./script/generate scaffold_resource Server name:string cat:string net_face:integer ids:integer mon_man:integer mon_aut:integer int_ip:string ext_ip:string desc:string bu_media:string bu_method:string bu_data_freq:string os_vendor:string os:string os_version:string ./script/generate scaffold_resource App name:string fsa:integer fsa_logic:string description:string bu_data:string ./script/generate scaffold_resource Db name:string cat:string description:string mon_man:integer mon_auto:integer ./script/generate scaffold_resource App_svr server_id:integer app_id:integer ./script/generate scaffold_resource Db_app db_id:integer app_id:integer ./script/generate scaffold_resource Db_svr db_id:integer server_id:integer rake db:migrate ##### In a restful way I have the URL''s working properly for: http://127.0.0.1:3000/dbs/ http://127.0.0.1:3000/apps/ http://127.0.0.1:3000/servers/ http://127.0.0.1:3000/db_apps/ http://127.0.0.1:3000/db_svrs/ http://127.0.0.1:3000/app_svrs/ Now my question is how to create a LOV in order to build my application for the Join tables in DB_APPS like to have the option to show the LOV based on the Databases, Applications or Servers table and not the ID. Also in the Form like to be able to select from the other table. For the Model how would exactly work the ... has_many :trough .... Thanks in advance for your help. Dino. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Dinooz
2007-Feb-21 16:49 UTC
Re: How to create a LOV [ List of Values in a Rails Application ]
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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Dinooz
2007-Feb-21 16:50 UTC
Re: How to create a LOV [ List of Values in a Rails Application ]
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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---