我们都知道html_safe在控制器和视图中工作 我正在从user_mailer.rb文件中发送一些数据,并且它有一些特殊字符,如果我写了&“samarth”,那么它的节目& amd& quotsamarth& quot 代码是
def alert_publication_notification(user,cust_alert,home_url)
load_mailer_settings
@content_type = "text/html"
@subject = ("[abc]- #{cust_alert.alert.name.html_safe} : mail ") due to this line i am getting special character any solution
@from = "sam"
@recipients = user.login
@bcc = Settings.emailid_alerts
@sent_on = Time.now
@customer_alert = cust_alert
@user = user
@home_url = home_url
端
答案 0 :(得分:1)
对RAILS 3使用raw(some_variable)
函数,这不会显示编码字符。