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.
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