Hi, I have values in my database stored as integers: 1, 2, 3, 4, 5 When I retrieve and display these values in a List or Show, I want to map them to text such as: Text1, Text2, Text3, Text4, Text5 What''s the easiest way to do this? Thanks, David -- 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-/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 -~----------~----~----~----~------~----~------~--~---
On Apr 2, 2007, at 5:09 PM, David Lelong wrote:> Hi, > > I have values in my database stored as integers: > > 1, 2, 3, 4, 5 > > When I retrieve and display these values in a List or Show, I want to > map them to text such as: > > Text1, Text2, Text3, Text4, Text5 > > What''s the easiest way to do this?Why aren''t they Text* already in the database? -- fxn --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I want to optimize the data in the database for summarizing. Xavier Noria wrote:> On Apr 2, 2007, at 5:09 PM, David Lelong wrote: > >> >> What''s the easiest way to do this? > > Why aren''t they Text* already in the database? > > -- fxn-- 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-/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 -~----------~----~----~----~------~----~------~--~---
On Apr 2, 2007, at 5:28 PM, David Lelong wrote:> I want to optimize the data in the database for summarizing.Optimization, it is really worth the trouble? That corner of the appliccation now is not smooth. Anyway, the getter cannot be redefined for that purpose because it is used by AR to read attributes to save them, and you need the conversion only towards the view. (Kernel.caller hacks notwithstanding.) An ad-hoc getter would be OK: def foo_without_database_optimization "Text#{foo}" end that one would be called in views instead of the real getter. -- fxn --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You could perhaps consider ENUM column type: http://dev.mysql.com/doc/refman/5.0/en/enum.html On Apr 2, 5:09 pm, David Lelong <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi, > > I have values in my database stored as integers: > > 1, 2, 3, 4, 5 > > When I retrieve and display these values in a List or Show, I want to > map them to text such as: > > Text1, Text2, Text3, Text4, Text5 > > What''s the easiest way to do this? > > Thanks, > > David > > -- > Posted viahttp://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-/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 -~----------~----~----~----~------~----~------~--~---