I have a form with many fields that can be changed. Company, Group, Facility, Department, User, etc... Each field has an associated table with the following fields(ID, NAME) If a Company, Group, or Department is changed, the ''CHANGES'' text field of the ''AUDITS'' table stores something like the following: --- company_id: - 111 - 222 group_id: - 333 - 444 department_id: - 555 - 777 This is what will show in my VIEW: company_id - 111 - 222 group_id - 333 - 444 department_id - 555 - 777 Instead of storing the ID, I want to store the actual NAME value so I can display something like the following in my VIEW: company_id - ABC COMPANY - XYZ COMPANY group_id - RED GROUP - GREEN GROUP department_id - ACCOUNTING - PAYROLL Anyone have any ideas on how this could be accomplished? Thanks, Frank -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Wed, 2010-02-03 at 12:38 -0800, Frank_in_Tennessee wrote:> I have a form with many fields that can be changed. Company, Group, > Facility, Department, User, etc... > > Each field has an associated table with the following fields(ID, NAME) > > If a Company, Group, or Department is changed, the ''CHANGES'' text > field of the ''AUDITS'' table stores something like the following: > --- > company_id: > - 111 > - 222 > group_id: > - 333 > - 444 > department_id: > - 555 > - 777 > > This is what will show in my VIEW: > company_id - 111 - 222 > group_id - 333 - 444 > department_id - 555 - 777 > > Instead of storing the ID, I want to store the actual NAME value so I > can display something like the following in my VIEW: > company_id - ABC COMPANY - XYZ COMPANY > group_id - RED GROUP - GREEN GROUP > department_id - ACCOUNTING - PAYROLL > > Anyone have any ideas on how this could be accomplished?---- you would have to extend the functionality of ''acts_as_audit'' plugin. Craig -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Feb-05 02:36 UTC
Re: acts_as_audited - save NAME value not ID value
Frank_in_Tennessee wrote:> I have a form with many fields that can be changed. Company, Group, > Facility, Department, User, etc... > > Each field has an associated table with the following fields(ID, NAME) > > If a Company, Group, or Department is changed, the ''CHANGES'' text > field of the ''AUDITS'' table stores something like the following: > --- > company_id: > - 111 > - 222 > group_id: > - 333 > - 444 > department_id: > - 555 > - 777 > > This is what will show in my VIEW: > company_id - 111 - 222 > group_id - 333 - 444 > department_id - 555 - 777 > > Instead of storing the ID, I want to store the actual NAME value so I > can display something like the following in my VIEW: > company_id - ABC COMPANY - XYZ COMPANY > group_id - RED GROUP - GREEN GROUP > department_id - ACCOUNTING - PAYROLL > > Anyone have any ideas on how this could be accomplished? >Don''t do that. Keep the data stored as ids in the DB, and get the names out of the appropiate table. If you do one query for all names, there shouldn''t be too much performance degradation.> Thanks, > > FrankBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.