Hi all, I''m looking to resolve foreign keys for forms -- similar to the way "streamlined" does it. Although the actual value stored in an object is the foreign key integer, I''d like the actual name of the item displayed. I''m *sure* it''s easy. Thoughts? Regards. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
So you have one object, say a user and another one that belongs to the user, say an address then: User model: has_one :address Address model belongs_to :user then after finding the user @user = User.find(params[:id]) you can access the address with @user.address or single address fields @user.address.city belongs_to and has_many have a lot of options. You can set a foreign_key if you don''t use the default user_id in the address table --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---