ruby on rails 3 - mailboxer - get recipient of a message -
i can last sender of message:
conversation.receipts_for(current_user).last.message.sender.name
but cannot recipient(s) of same message. display gmail-esk:
sender name, recipient name | subject | date
any ideas?
i created method in helper file:
def participant_names(conversation) conversation.receipts.reject { |p| p.receiver == current_user }.collect {|p| p.receiver.name }.uniq.join(" ,") end
what doing is, removing current_user conversation object, creates new array contains names (in case users) conversation object. '.uniq' method ensures each users name displayed once (in case there have been many message , forth conversation). comma separates them.
Comments
Post a Comment