Search code examples
htmlruby-on-railsmailto

Button_to remove auth token


I use this code to allow the user to send a mail to another user:

<%= button_to("Contact me","mailto:#{@formation.usr.email}?subject=#{@formation.name}", class: "fiche__detail__contact") %>

Which gives me the following html:

<form action="mailto:user@gmail.com?subject=SomeName" class="button_to" method="post">
    <div>
        <input class="fiche__detail__contact" type="submit" value="Me contacter" />
        <input name="authenticity_token" type="hidden" value="cO0XDBcG4j0IfmDJV56sdYSfoLeV9NmhTd+bJu/ku+U=" />
    </div>
</form>

And this king of email:

enter image description here

I tried to set the body of the mail using &body but it doesn't work. Also, set :authenticity_token => false is not working either.

How can I remove the token?


Solution

  • Just use mail_to:

    <%= mail_to @formation.usr.email, "Contact me", :subject => @formation.name, class: "fiche__detail__contact" %>