Message.create(content:"hello",send_user:5,recieve_user:6,create_time:DateTime.now,readed:false) user.send_messages.find_by(send_user:user.id)[:recieve_user] user.send_messages.select("recieve_user"). user.send_messages.select(:recieve_user).find(1).recieve_user Message.where(send_user:5,recieve_user:6) Message.where(send_user:[6,8],recieve_user:[6,8]).select(:send_user,:recieve_user) user.recieve_messages.where(readed: false).count