Alex Rivera | Logout

Getting [email protected] when trying to display eamil using collection_select

Asked 2010-10-11T22:17:36.007
20

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/>
Edit
Report

1 Answer

53

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:

answered 2010-10-21T14:19:00.870

Your Answer