I am trying to display just the last post for each user and having messed around for a while, I cannot work it out.
I have relationships of users has many posts and posts belong to users. When I use the below code it correctly puts each users email address but it puts the value for each post as the last overall value (not the last value for that specific user).
<% @users.each do |u| %>
<%= @posts.last.total %>
<%= u.email %>
<% end %>
(Total is a calculation performed in posts model and saved in the db.)