daf-tYLKPQIqrbEAvxtiuMwx3w@public.gmane.org
2005-Feb-16 15:07 UTC
ActiveRecord dropping fields
I have this MySQL table: CREATE TABLE `cc_perf` ( `card_holder_id` varchar(20) default NULL, `claim_id` int(11) NOT NULL default ''0'', `received_time` datetime NOT NULL default ''0000-00-00 00:00:00'', `total_process_time` int(11) NOT NULL default ''0'', `care_claim_process_time` int(11) NOT NULL default ''0'', `ivans_enum_sts` enum (''ELIGIBLE'',''NOT_ELIGIBLE'',''SYSTEM_NOT_AVAILABLE'',''PROCESSING_FAILURE'') default NULL, `ivans_status` int(11) NOT NULL default ''0'', `ivans_process_time` int(11) NOT NULL default ''0'', `terminal_id` varchar(4) NOT NULL default '''', `provider_id` varchar(20) NOT NULL default '''', `rx_number` varchar(20) NOT NULL default '''', `refills` int(11) NOT NULL default ''0'', `claim` text NOT NULL, `response` text NOT NULL, UNIQUE KEY `claim_id` (`claim_id`), ) When I use the default ActiveRecord scaffolding, the "new" page does not include the "card_holder_id", "claim_id", "provider_id" and "terminal_id" fields. Since this is a legacy system, I need to get to these fields. If I use this code as "new" : <% for attr in @claim.attribute_names %> Attr: <%= attr %> = "<%= @claim[attr] %>" <br/> <% end %> I can see all the fields. I''m assuming this has something to do with the "_id" that is part of these names. So far, I have found out how to set the name of the legacy table for the Claim model: class Claim < ActiveRecord::Base def self.table_name() "cc_perf" end end but I cannot find a way around this problem of missing fields. Is there a similar work-around for these poorly named legacy fields?
According to daf-tYLKPQIqrbEAvxtiuMwx3w@public.gmane.org:> but I cannot find a way around this problem of missing > fields. Is there a similar work-around for these poorly > named legacy fields?You can not use the default scaffoling system as it hides the _id fields as you''ve found. -- Ollivier ROBERT -=- FreeBSD: The Power to Serve! -=- roberto-0kjVc+YyuDZX+h8frlqCcVAUjnlXr6A1@public.gmane.org Darwin snuadh.freenix.org Kernel Version 7.8.0: Wed Dec 22 14:26:17 PST 2004
On Wed, 16 Feb 2005 daf-tYLKPQIqrbEAvxtiuMwx3w@public.gmane.org wrote:> I have this MySQL table: > > CREATE TABLE `cc_perf` ( > `card_holder_id` varchar(20) default NULL, > `claim_id` int(11) NOT NULL default ''0'', > `received_time` datetime NOT NULL default ''0000-00-00 00:00:00'', > `total_process_time` int(11) NOT NULL default ''0'', > `care_claim_process_time` int(11) NOT NULL default ''0'', > `ivans_enum_sts` enum > (''ELIGIBLE'',''NOT_ELIGIBLE'',''SYSTEM_NOT_AVAILABLE'',''PROCESSING_FAILURE'') > default NULL, > `ivans_status` int(11) NOT NULL default ''0'', > `ivans_process_time` int(11) NOT NULL default ''0'', > `terminal_id` varchar(4) NOT NULL default '''', > `provider_id` varchar(20) NOT NULL default '''', > `rx_number` varchar(20) NOT NULL default '''', > `refills` int(11) NOT NULL default ''0'', > `claim` text NOT NULL, > `response` text NOT NULL, > UNIQUE KEY `claim_id` (`claim_id`), > ) > > When I use the default ActiveRecord scaffolding, the "new" page does not > include the "card_holder_id", "claim_id", "provider_id" and "terminal_id" > fields. > > Since this is a legacy system, I need to get to these > fields. If I use this code as "new" : > > <% for attr in @claim.attribute_names %> > Attr: <%= attr %> > = "<%= @claim[attr] %>" > <br/> > <% end %> > > I can see all the fields. I''m assuming this has something > to do with the "_id" that is part of these names. So far, > I have found out how to set the name of the legacy table > for the Claim model: > class Claim < ActiveRecord::Base > def self.table_name() > "cc_perf" > end > end > but I cannot find a way around this problem of missing > fields. Is there a similar work-around for these poorly > named legacy fields?create a view of your table which does not name things *_id. -a -- ==============================================================================| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | When you do something, you should burn yourself completely, like a good | bonfire, leaving no trace of yourself. --Shunryu Suzuki ===============================================================================
On 16.2.2005, at 17:07, daf-tYLKPQIqrbEAvxtiuMwx3w@public.gmane.org wrote:> > but I cannot find a way around this problem of missing > fields. Is there a similar work-around for these poorly > named legacy fields?You''re not going to use scaffolding in your production system anyway, it''s only meant for rapid prototyping. You can create form fields for those fields just like for other fields when you create a custom form. BTW, aren''t those id''s foreign key fields (except claim_id which seems to be the primary key)? //jarkko> > > > > > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Jarkko Laine http://jlaine.net http://odesign.fi _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails