Whitelist params w/ form_with (no model) in Rails

I’m trying to implement a Mail Controller for my “Contact Us” page in Rails 6. I have the route, controller, and call to the mailer controller set up. I’m able to receive the email, but I’m having trouble getting the params from the view to the mailer. I’m getting an error for the token when I try to whitelist the param.

#route
  get "/contact-us", to: 'home#contact', as: 'home_contact' 
  post "/contact-us", to: 'home#contact_send_email', as: 'home_contact_send_email' 

My controller code is as follows:

#controller page 
...
 def contact
 end

def contact_send_email # POST Method 

UserMailer.with(contact_params).contact_email.deliver_later
    redirect_to( home_contact_path)
  end   
private
def contact_params
      params.permit(:name) 
end
...

The relevant part of my view is as follows:

# view # home >contact.html.erb

...
<%= form_with( url:  home_contact_send_email_path, method: "post") do |form| %>
<%= form.label :name, class:"label" %>
<%= form.text_field :name, class:" field input is-medium"%>
...

I’m getting the error Unpermitted parameters: :authenticity_token when I run my code. I tried using params.require(:home).permit(:name) but I got the error parameters for home are empty.

My question is: is it possible to whitelist parameters when using form_with url without creating a model? If not, is there a better way?

Yes, it is possible to whitelist parameters when using form_with url without creating a model. However, you need to include the authenticity token in the list of permitted parameters. To do this, update your contact_params method to permit the authenticity token as well:

def contact_params
  params.require(:home).permit(:name, :authenticity_token)
end