Mailboxer messages not arriving in recipients inbox


#1

I don't know what's going wrong Here's my log and my code:

Started POST "/messages" for ::1 at 2017-09-24 02:47:27 -0400
Processing by MessagesController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"T1Vcu9Crfcj7HQnoxGD1JGBuHxx7zVgm4xZ8JIh/C2JdXg3KA/VrDEfapY3nb1AN1ztc/pXoFVqbr3XkE42lZQ==", "message"=>{"subject"=>"test", "body"=>"test", "recipient"=>"JackBower"}, "commit"=>"Send"}
  e[1me[36mUser Load (0.8ms)e[0m  e[1me[34mSELECT  `users`.* FROM `users` WHERE `users`.`id` = 1 ORDER BY `users`.`id` ASC LIMIT 1e[0m
  e[1me[35m (0.4ms)e[0m  e[1me[35mBEGINe[0m
  e[1me[35mSQL (0.6ms)e[0m  e[1me[32mINSERT INTO `mailboxer_conversations` (`subject`, `created_at`, `updated_at`) VALUES ('test', '2017-09-24 06:47:27', '2017-09-24 06:47:27')e[0m
  e[1me[35mSQL (0.9ms)e[0m  e[1me[32mINSERT INTO `mailboxer_notifications` (`type`, `body`, `subject`, `sender_type`, `sender_id`, `conversation_id`, `updated_at`, `created_at`) VALUES ('Mailboxer::Message', 'test', 'test', 'User', 1, 37, '2017-09-24 06:47:27', '2017-09-24 06:47:27')e[0m
  e[1me[35mSQL (0.8ms)e[0m  e[1me[32mINSERT INTO `mailboxer_receipts` (`receiver_type`, `receiver_id`, `notification_id`, `is_read`, `mailbox_type`, `created_at`, `updated_at`) VALUES ('User', 1, 39, 1, 'sentbox', '2017-09-24 06:47:27', '2017-09-24 06:47:27')e[0m
e[1me[35m (62.2ms)e[0m e[1me[35mCOMMITe[0m

 messages_controller.rb
class MessagesController < ApplicationController
  before_action :authenticate_user!

  def new
   @recipients = User.find_by_name(params[:name]).name
  end

  def create
    recipient=params[:recipient]
    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
new.html.erb
<% name = @recipient %>
<%= (t 'starting_a_conversation_with') %><%= " " %><b><%= name %></b>
<br><br>
<%= form_tag messages_path, method: :post do %>
  <div class="form-group">
    <%= label_tag 'message[subject]', 'Subject' %>
    <%= text_field_tag 'message[subject]', nil, class: 'form-control', required: true %>
  </div>

  <div class="form-group">
    <%= label_tag 'message[body]', 'Message' %>
    <%= text_area_tag 'message[body]', nil, cols: 3, class: 'form-control', required: true %>
  </div>

  <div class="form-group">
    <%= hidden_field_tag 'message[recipients]', @recipient, class: 'form-control' %>
  </div>

  <%= submit_tag 'Send', class: 'btn btn-primary' %>
<% end %>

#2

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.