2012-12-02 42 views
0

我使用的鐵軌3.2.8。Rails應用郵件的JavaScript,紅寶石與JavaScript混?

http://www.railsmine.net/2010/03/rails-3-action-mailer-example.html

,但似乎都不盡如人意教程。

似乎有問題識別嵌入Ruby代碼內

代碼的JavaScript,我認爲原因

def support_notification(sender) 
    @sender = sender 
    mail(mail(:to => "[email protected] <script type="text/javascript"> 
    /* <![CDATA[ */ 
    (function(){try{var  
    s,a,i,j,r,c,l=document.getElementById("__cf_email__");a=l.className;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){}})();/* ]]> */ 
    </script>", 
    :from => sender.email, 
    :subject => "New #{sender.support_type}") 
end 

錯誤提示

app/mailers/notifier.rb:6: syntax error, unexpected tIDENTIFIER, expecting ')' 
...ourdomain.com<script type="text/javascript"> 
...        ^

app/mailers/notifier.rb:6: syntax error, unexpected tSTRING_BEG, expecting keyword_do or  
'{' or '('...m<script type="text/javascript"> 
      ...        ^
app/mailers/notifier.rb:8: syntax error, unexpected tIDENTIFIER, expecting keyword_end 
    ...nt.getElementById("__cf_email__");a=l.className;if(a){s='';r... 
    ...        ^

app/mailers/notifier.rb:12: syntax error, unexpected ')', expecting keyword_end 

回答

1

的問題,也許有一個錯誤提到博客的JavaScript,它爆炸附近的任何電子郵件地址,可能是你想要的代碼如下:

def support_notification(sender) 
    @sender = sender 
    mail(:to => "[email protected]", 
    :from => sender.email, 
    :subject => "New #{sender.support_type}") 
end 
+0

感謝......我是一個白癡...哈哈 – runcode