Closed dummied closed 8 years ago
https://github.com/SherSpock/muscle-wizards/blob/master/app/controllers/application_controller.rb#L16-L20
I'm thinking something like conversation.unread_count(user)
conversation.unread_count(user)
def unread_count(user) this_user = user == recipient ? sender : recipient messages.where(user: this_user, read: false).count end
Then, ideally, you can go a level higher in Prep:
def unread_count(user) Conversation.between(athlete_id, coach_id).first.unread_count(user) end
Your mileage may vary, but I think this would get new_message_count down to:
def new_message_count @prep.unread_count(current_user) end
https://github.com/SherSpock/muscle-wizards/blob/master/app/controllers/application_controller.rb#L16-L20
I'm thinking something like
conversation.unread_count(user)
Then, ideally, you can go a level higher in Prep:
Your mileage may vary, but I think this would get new_message_count down to: