我按照这个网站的教程将mailboxer 实现到Ruby on Rails Web 应用程序中。
现在我收到这个错误:
ArgumentError in Messages#create
Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
这是我的messages_controller.rb
class MessagesController < ApplicationController
def new
@chosen_recipient = User.find_by(id: params[:to].to_i) if params[:to]
end
def create
recipients = User.where(id: params['recipients'])
conversation = current_user.send_message(recipients, params[:message]
[:body], params[:message][:subject]).conversation
flash[:success] = "Message has been sent!"
redirect_to conversation_path(conversation)
end
end
我不确定它有什么问题,因为我完全按照教程进行操作。
错误行具体是第 9 行“conversation = current_user.send_message......”
我相信我必须在某处定义@recipients,但本教程没有指定。
我已经尝试过@recipients 和@conversations,这只会导致另一个我不熟悉修复的错误(这只是为了实验)。
所有代码都在教程中,并在顶部链接。
可以在此链接上克隆存储库(使用 AWS Cloud9)并创建用户,然后尝试向另一个用户发送消息,当单击将消息发送给收件人时,您将收到错误消息。
我已经尝试执行之前列出的建议并尝试@ing 一些变量,但它没有奏效。