I have a model Messages w the fields: id, message, read, view_count. View count is calculated from another table, it's not in the message model
What I want to do is loop over all the Messages and track all unreads (read = false) and the view count per the unreads to output something like this:
1, "message stuff", false, 14
2, "message stuff", false, 31
3, "message stuff", false, 1
While looping through messages like so:
Messages.each do |m|
end
In the loop, how can I build an array that captures the message.id and the view_count. And then how can I output the final result?
Thank you