How can I have the recipient field default to specific users?

How can I have the recipient field default to specific users?

<strong>QUESTION: How can I have the recipient field, automatically filled out, with a user's username, for example, using the MailBoxer gem?</strong>

QUESTION: How can I have the recipient field, automatically filled out, with a user's username, for example, using the MailBoxer gem?

I have a user admin account, and I want to have the recipient field pre-filled out, when I click on a user (non admin) profile page, in the show.html.erb view.

Currently, the code used displays ALL users utilising the platform, whereas I want this specific form to only display the recipient.

I am using the mailboxer gem, and I have the subject and message field already pre-filled and working.

The code for the form, which is in the show.html.erb view:

<%= form_for :conversation, url: :conversations, html: { class: "" } do |f| %>

<div class="form-group"> <%= f.label :recipients %> <%= f.select(:recipients, User.all.collect {|p| [ p.username, p.id ] }, {}, { multiple: true , class: "chosen-select form-control", :data => {:placeholder => "Please type in a username to search for a user"}})%> </div>

<div class="form-group"> <%= f.label :subject %> <%= f.text_field :subject, placeholder: "Subject", class: "form-control", value: "Hi #{@user.username}! %> </div>

<div class="form-group"> <%= f.label :message %> <%= f.text_area :body, class: 'form-control',placeholder: "Type your message here", rows: 4, value:

"Hi #{@user.username}!

I am mailing you to tell you that [INSERT ITEM NAME] is in stock.

Please come down to receive the item. %> </div>

<%= f.submit "Send Message" %>

<% end %>


Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Ruby on Rails vs PHP

Understanding the pros and cons of Ruby on Rails versus PHP is important when deciding how to create your business-critical applications.