I have a user view and a rental view. In my rental view im trying to show the current users name. I think I am pretty close but I can\'t work out this last bit.
This ret
I am assuming you have a rental object, for which you show the form, I assume it is an instance variable @rental
, furthermore I assume that inside your Rental
class there is the following relation
class Rental
belongs_to :user
end
Then you could just write the following:
f.select :user_id, [[@rental.user.user_name, @rental.user.id]]
Hope this helps.
On a related but less important note: it is really weird to have a column called user_name
for a user
: I would call that column just name
, since it is part of a user anyway.