mailboxer细节知识点

` @conversation = current_user.send_message(@user , params[:body] , @order.post.title, @order).conversation` 括号里面分别对应的是(收件人,message内容,subject,order_two_id),今天就卡在无法赋给conversation order_two_id这个值,原因是模改conversation后还要对send_message这个方法进行重写。要不然send_message是默认你没有这个值,就不会给你传值。 在user model里面加一个def

def send_message(recipients, msg_body, subject, order, sanitize_text = true, attachment = nil, message_timestamp = Time.now) #加入order参数
    convo = Mailboxer::ConversationBuilder.new(subject: subject,
                                               created_at: message_timestamp,
                                               updated_at: message_timestamp).build

    message = Mailboxer::MessageBuilder.new(sender: self,
                                            conversation: convo,
                                            recipients: recipients,
                                            body: msg_body,
                                            subject: subject,
                                            attachment: attachment,
                                            created_at: message_timestamp,
                                            updated_at: message_timestamp).build

    convo.order_two_id = order  #保存参数
    convo.save

    message.deliver false, sanitize_text
  end