In my mailer, I am generating a link to my sign up form so that I can include it in the email to the user. I'd like to prepopulate the sign up form with the user's name and email address.
I create an instance variable @signup_query like so:
@signup_query = "?name=" <<
CGI.escape(@name) <<
"&" <<
"email=" <<
CGI.escape(@email)
But when I call link_to
in my view, Rails encodes the query string, which adds 'amp;' to the '&'. As a result, my params
hash has key 'amp;email' instead of key 'email' so in my sign up view, I have this ugliness:
= f.email_field :email, class: 'form-control', :value => params['amp;email']
This works but I know there must be a better way.
Try this
in your mailer.
For more details on link_to use this