I m using Devise, so I have a user table. I have added an Employee table and a Contact table (customer contacts). Each Employee and Contact will have their own user_id.
What would be the best approach for setting up the table relationships?
(1) 雇员和联系人是否属于:用户?
2) 吗?
成就
A. 更新 ================================================================================================================================================================================================================================================================
I changed the code as Yosep said.
但是,我可以说明如何在用户指数表中从雇员记录中显示田地。 例如,用户名单(指数)应当包含雇员。 我尝试了这句话。
<% @users.each do |user| %>
<tr>
<td><%= user.id%></td>
<td><%= Employee.where(:user_id => user.id).first_name %> </td><td><%=
我试图这样做:
<td><%= Employee.find_by_user_id(user).first_name %> </td> code