0

I followed this site's tutorial on implementing mailboxer into a Ruby on Rails web application.

Right now I'm getting this error:

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

Here is my 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

I'm not sure what is wrong with it as I followed the tutorial fully.

The error line specifically is line 9 "conversation = current_user.send_message......"

I believe I would have to define @recipients somewhere but the tutorial doesn't specify.

I have tried @recipients and @conversations that only leads to another error that I'm not familiar with fixing (this was just for experimentation).

All the code is in the tutorial as well linked at the top.

The repo can be cloned at this link (using AWS Cloud9) and create users to then try to message another user and you will get the error message when clicking to send the message to the recipient.

I have tried to do the suggestions previously listed and experimented with @ing some of the variables but it did not work.

halfer
  • 19,824
  • 17
  • 99
  • 186
layaslaya
  • 1
  • 2

1 Answers1

0

You need to tell Rails where your email server is in each of your application's environment files. Something like:

config.action_mailer.default_url_options = { :host => "www.yourhost.com" }

Also, before you post a question here, you should try searching Google for the error message. This was the first result for Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true

David Klinge
  • 362
  • 1
  • 9