I have a user table and an employee table. They have a one-to-one relationship.
When I create a time-entry record, I would like to automatically assign the current employee.
What I have access to is the current_user.
The employee table has a foreign key (user_id).
I tried this in the form – but it didn’t work:
<%= f.hidden_field :employee_id, :value => current_user.employee.employee_id %>
Do I need to add a foreign key to the user table = employee_id ?
Thanks
So your employee model
and your user model
Is that right?
If so, it might be as simple as changing the hidden field value to
(rather than current_user.employee.employee_id).
If that doesn’t work, can you post exactly how you’re constructing the one-to-one relationship?