0
我無法使發送消息按鈕與郵箱gem一起工作。我將本教程用作指南'http://josephndungu.com/tutorials/private-inbox-system-in-rails-with-mailboxer',與其他許多人一樣,您必須從所有用戶的列表中選擇收件人。紅寶石軌道上。郵箱發送消息按鈕
我想要一個按鈕,直接發送沒有列表的消息,因此我在頁面上發送了「發送用戶消息」按鈕,將用戶標識傳遞給新的對話表單。
郵件沒有發送,只在發送者發送的郵箱中顯示。
這裏是我的代碼:
<%= link_to '', new_conversation_path(:recipients_id => @user.id), class: 'send-message-icon' %>
也試過:
<%= link_to '', new_conversation_path(:recipients_id => @user), class: 'send-message-icon' %>
_form:(正確的用戶ID顯示在文本框中我將在稍後刪除文本框)
<%= form_for :conversation, url: :conversations, html: { class: "" } do |f| %>
<div class="form-group">
<%= f.label :recipients %>
<%= f.text_field :recipients, :value => params[:recipients_id]%>
</div>
<div class="form-group">
<%= f.label :subject %>
<%= f.text_field :subject, placeholder: "Subject", class: "form-control" %>
</div>
<div class="form-group">
<%= f.label :message %>
<%= f.text_area :body, class: 'form-control',placeholder: "Type your message here", rows: 4 %>
</div>
<%= f.submit "Send Message", class: "btn btn-success" %>
控制器:
def create
recipients = User.where(id: conversation_params[:recipients])
conversation = current_user.send_message(recipients, conversation_params[:body], conversation_params[:subject]).conversation
flash[:success] = "Your message was successfully sent!"
redirect_to conversation_path(conversation)
end
用戶模式:
acts_as_messageable
before_destroy { messages.destroy_all }
我不明白爲什麼它不工作。任何建議,將不勝感激,謝謝。