I have this in the index view:
<% @submissions.each do |submission| %>
<tr>
<td><%= submission.id %></td>
<td><%= User.find_by_id(submission.user_id).name.to_s %></td>
</tr>
<% end %>
I know I am not supposed to use find_by in the view.
How can I move this to the controller (or model)?
I tried to insert this in the index method of my submission controller and using the username variable but it doesn't work.
def index
@submissions = Submission.all
@submissions.each do |submission|
username = User.find_by_id(submission.user_id).name.to_s
end
end