I just built a really simple mailer using Rails 6 and when i deployed to production the error popped up, saying i was missing the User param is missing, fyi, is just a landpage with the form where you do not have to log in to send anything, you just fill it out and we get the information thru the email. here is the form view:
<div class="form">
<div class="row">
<%= form_for :contact, url: send_contact_path do |f| %>
<%= f.text_field :name, placeholder: "Full Name" %>
<%= f.text_field :email, placeholder: "Email Address" %>
<%= f.text_field :phone_number, placeholder: "Phone Number" %>
</div>
<div class="row">
<%= f.text_field :partner_name, placeholder: "Partner's Full Name" %>
<%= f.text_field :partner_email, placeholder: "Partner's Email" %>
<%= f.text_field :partner_phone, placeholder: "Partner's Phone" %>
</div>
<div class="row">
<%= f.select(:category, categories, placeholder: "Category") %>
<%= f.number_field :paid_amount, step: 0.01, placeholder: "Amount Paid" %>
</div>
<%= f.text_area :message, placeholder: "Anything you would want to say" %>
<%= f.submit "Send Info" %>
<% end %>
</div>
here is the controller:
def create_contact
contact = User.new(contact_params)
if contact.save
send_contact(contact)
send_copy(contact)
flash[:success] = 'Message sent successfully!'
else
redirect_to root_path
flash[:notice] = 'Error, try again'
end
end
private
def contact_params
params.require(:user).permit(:name, :email, :phone_number, :partner_name, :partner_email, :partner_phone, :message, :amount_paid, :category)
end
def send_contact(contact)
mail = Mailjet::Send.create(messages: [{
"From"=> {
"Email"=>"email",
"Name"=>"name"
},
"To"=> {
"Email"=>"email",
"Name"=>"name"
},
"Subject"=>"subject",
"HTMLPart"=>template(contact)
}])
end
thanks, im using pg as the db and mailjet as the mailing service