Question

I am using Ruby 1.8.7 with Rails 2.3.9. When creating a drop down of email addresses using collection select, the emails addresses are not displaying. Instead I am seeing "[email protected]" in the drop down. Is there some switch that is causing this?

There seems to be some javascript that is being applied to each item in the drop down by rails when it sees an email in the list. The javascript is not there when I just list the user names.

<script type="text/javascript">
/* <![CDATA[ */
3(function(){try{var s,a,i,j,r,c,l=document.getElementById("__cf_email__");a=l.getAttribute("cf_sec");if(a){s='';r=parseInt(a.substr(0,2),16);for(j=2;a.length-j;j+=2){c=parseInt(a.substr(j,2),16)^r;s+=String.fromCharCode(c);}s=document.createTextNode(s);l.parentNode.replaceChild(s,l);}}catch(e){}})();
4/* ]]> */ 
<script/>
Was it helpful?

Solution

Hoa you are correct this isn't rails related.

I found that this caused by the CDN we are using CloudFlare. As part of their security settings they obscure emails.

You can turn this off by going to the CloudFlare settings on your CloudFlare account and turn off E-mail Address Obfuscation.

Update: This is definitely a CloudFlare setting that prevents emails from being displayed (saw this happen in my active_admin), but know that you can also add some HTML to the output that CloudFlare will look for around the email output:

<!--email_off--> email@example.com <!--/email_off-->

Reference:

OTHER TIPS

Adding to @Nicolo77 answer.

I have ran into same issue. Cloud flare by default Turn on Email Address Obfuscation. You can change it on your could flare dashboard:

Login->Scrape Shield->Email Address Obfuscation -> Turn Off

The should be a switch when you go to Security Settings -> E-mail Address Obfuscation .

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top