Does Rails have the ability to translate a code to a literal? I have a data table with 3 columns in it: Id MenuItemName MenuItemType -- -------------- ------------ 1 Toast 2 2 Turkey 3 3 Corn Flakes 2 I have a support data table with values of: Id MenuItemTypeDescription -- ----------------------- 1 Lunch 2 Breakfast 3 Dinner I have set the database up with foreign keys to tie the tables together and have added the "belongs_to" and "has_many" to the model classes. I was hoping that rails would translate he MenuItemType to the description for the display list and when doing and add or edit it would have a dropdown box that would list all the MenuItemType Descriptions. This may be just a dream. I have searched the Rails "Agile Development" book and the Rails forums, but I haven''t found anything on this topic. Is this supported by the Rails framework or do you have to code this functionality by hand? -- 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 -~----------~----~----~----~------~----~------~--~---
Rodney Baker wrote:> I was hoping that rails would translate he MenuItemType to the > description for the display list and when doing and add or edit it would > have a dropdown box that would list all the MenuItemType Descriptions. > This may be just a dream. > > Is this supported by the Rails framework or do you have to code this > functionality by hand?Yes, you have to add this functionality to the form yourself. Check this out...I think this is what you''re trying to do => collection_select http://wiki.rubyonrails.org/rails/pages/HowtoUseFormOptionHelpers -- 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 -~----------~----~----~----~------~----~------~--~---
However, I''ll have to warn you as I''m no expert on this topic either. I''m having my own problems with the collection_select. I can''t seem to get it to recover from validation errors. You can look at my detailed example though and see what I''m doing. I can add and edit all day but it bombs on me when I have a validation error. Good luck! http://www.ruby-forum.com/topic/92296 -- 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 -~----------~----~----~----~------~----~------~--~---
Thanks for the response. -- 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 -~----------~----~----~----~------~----~------~--~---