1
나는 메시징 기능을 위해 Mailboxer gem을 사용하고 있지만, 나는 아주 새 것이므로 사용법을 잘 모르고있다. 기본적으로 나는 다음과 같은 메시지가 컨트롤러를 생성 :Rails mailboxer gem이 메시지를 보낼 수 없다.
class MessagesController < ApplicationController
before_action :set_message, only: [:new, :create]
def new
@message = Message.new
end
def create
current_user.send_message(@recipient, message_params(:body, :subject))
redirect_to conversations_path
end
private
def set_message
@recipient = User.find(params[:recipient_id])
end
def message_params
params.require(:message).permit(:body, :subject)
end
end
그리고 내보기 :
<h1>New Message</h1>
<%= simple_form_for(@message, html: {class: "form-horizontal"}) do |f| %>
<%= f.error_notification %>
<%= f.input :subject %>
<%= f.input :body, as: :text, input_html: { rows: "3"} %>
<div class="form-actions">
<%= f.button :submit, class: "btn btn-primary" %>
</div>
<% end %>
하지만 메시지 ... 을 (BTW 내가 메시지가 콘솔로 보낼 수 있으며, 또한 대체 보낼 수 없습니다 "current_user.send_message (@recipient,"테스트 ","테스트 ")"와 메시지 컨트롤러의 일부,하지만 확실히 내가 원하는하지 무슨 일이)
또한 정확한 스택 오류를 게시하면 편리 할 것입니다 ... – David
답변을 알아 냈습니까? 지금 그것을하려고하면 나는 정의되지 않은 모델 이름을 가진 오류가 발생합니다. 나는 보석이 그것을 돌봐야하지 않기 때문에 이해하지 못한다? 메시지 모델을 만들어야합니까? 그렇다면 테이블에 무엇이 필요합니까? – Philip7899