Reputation: 581
How I permit that the current_user see just user created for him? When I create a user I add a father_id in new user, and I need show in just users created in index.html.erb
<table class="table table-striped custab">
<thead>
<tr>
<th>Email</th>
<th>User Father</th>
</tr>
</thead>
<tbody>
<% if current_user.father_id.present? %> // WRONG LOGIG!
<% @users.each do |user| %>
<tr>
<td><%= user.email %></td>
<td><%= user.father_id %></td>
</tr>
<% end %>
<% else %>
<p>No one user created</p>
<% end %>
</tbody>
</table>
For now, I can see all, but I need just show the created for current_user. How I can do it?
Upvotes: 1
Views: 36
Reputation: 581
def index
@users = User.where(father_id: current_user.id)
end
Sorry, the answer was on user_controller!
Upvotes: 1