Like the left column of Facebook's messaging interface, I want to make a list of users who have messaged or currently send messages to the user, effectively create a list of 'conversations'.
Then the item in this list can be clicked to show the history of the message between two users, which is actually a real conversation, which I am already working like
message.where ("(sender_id =? And user_id =?) Or (sender_id =? And user_id =?)", From_id, to_id, to_id, from_id) How do railway guides make such a conversation? User Where some current user is mailed to or current_user.messages unique users' map, order (message created_atam) ? (Precise Code-Code) Association Schema:
Class User & lt; ActiveRecord :: Base has_many: message and class message & lt; ActiveRecord :: Base population: user's end
I will create a connection between the user and the message And then the following
users. There (id: current_user.id) .joins (: message) .order ('messages.created_at DESC')
No comments:
Post a Comment