I have just started up grading to Rails 3. mail_to no longer works, you just get a lot of garbage. With what do I replace it?
Thanks
Paul Thompson
I have just started up grading to Rails 3. mail_to no longer works, you just get a lot of garbage. With what do I replace it?
Thanks
Paul Thompson
"Paul Jonathan Thompson" <rails001@gmail.com> wrote in message news:h2p603755611004142229h2d4f7013pde4320967c722e0e@mail.gmail.com...
I have just started up grading to Rails 3. mail_to no longer works, you just get a lot of garbage. With what do I replace it?
The mail_to helper is still present in edge Rails, so I'm not sure what is going wrong. Can you provide an example of your invocation, and what it is outputting?
Hi,
I am using Rails 3 Beta 3. The code is:
<%= mail_to(supplier.email, h(supplier.email), :subject => "Bathroom Direct Order:", :encode => "javascript") %>
This has worked fine up till Rails 2.3.5. Below is what now appears in the view:
<script type="text/javascript">eval(decodeURIComponent('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%70%6f%72%69%72%75%61%40%61%64%76%61%6e%63%65%65%6c%65%63%74%72%69%63%61%6c%2e%63%6f%2e%6e%7a%3f%73%75%62%6a%65%63%74%3d%42%61%74%68%72%6f%6f%6d%25%32%30%44%69%72%65%63%74%25%32%30%4f%72%64%65%72%25%33%41%22%3e%70%6f%72%69%72%75%61%40%61%64%76%61%6e%63%65%65%6c%65%63%74%72%69%63%61%6c%2e%63%6f%2e%6e%7a%3c%2f%61%3e%27%29%3b'))</script>
Guidance will be most welcome.
Regards,
Paul
Isn't that rails obfuscating the mailto link so that parsers cannot harvest email addresses so easily? Does the mailto link work if you follow it?
HTH
Matt
Hey Paul,
That javascript looks correct. mail_to should return an html_safe string. Escaped html indicates it isn't.
So if the problem is that the html is being escaped, then this is a bug. file a ticket on the rails lighthouse.
To get around the bug, use <%=raw mail_to(...) %> or <%= mail_to(...).html_safe %>
Regards Kieran
Hi Kieran,
Thanks for that. The raw option worked. I will file a ticket on the rails lighthouse.