Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 特殊字符被替换_Ruby On Rails_Ruby_Ruby On Rails 3_Ruby On Rails 3.1 - Fatal编程技术网

Ruby on rails 特殊字符被替换

Ruby on rails 特殊字符被替换,ruby-on-rails,ruby,ruby-on-rails-3,ruby-on-rails-3.1,Ruby On Rails,Ruby,Ruby On Rails 3,Ruby On Rails 3.1,这是我将主题行传递给方法的一种方式 @subject_text = html_subject(@customer_alert.alert.name) @subject_text = html_sub(@customer_alert.alert.name) 这是我想替换所有特殊角色的两种方法 def html_subject(s) s = s.to_s if s.html_safe? s else s.gsub(/[&><

这是我将主题行传递给方法的一种方式

@subject_text = html_subject(@customer_alert.alert.name)
@subject_text = html_sub(@customer_alert.alert.name)
这是我想替换所有特殊角色的两种方法

def html_subject(s)
  s = s.to_s
  if s.html_safe?
    s
  else

    s.gsub(/[&><"]/) { |special| CustomerAlert::SUBJECT_LINE[special] }
  end
 end
def html_sub(s)
  s = s.to_s
  if s.html_safe?
    s
  else

   if s.gsub(/&/,'&')
   end
   #{ |special| CustomerAlert::SUBJECT_LINE[special] }

   if s.gsub(/>/,'>')
   end

   if  s.gsub(/&lt;/,'<')
   end

   if s.gsub(/&quot;/,'"')

end
 s
   end
  end
def html_主题
s=s.to_
如果安全的话?
s
其他的
s、 gsub(/[&;“]/){|特殊|客户专家::主题(行[特殊]}
结束
结束
def html_接头(s)
s=s.to_
如果安全的话?
s
其他的
如果s.gsub(/&;/,“&”)
结束
#{|特殊|客户专家::主题行[特殊]}
如果s.gsub(/,“>”)
结束

如果s.gsub(/,“代替此选项,则可以使用“清理帮助器”删除特殊字符

检查链接:

如果我的案例取代了我的&amd;“,”rr替换为“我想用我的案例取代了我的&amd;”,rr替换为"我想用orignal signal替换它如果你想显示这样的输出,我想你不需要转换特定的字符。Rails view helper将自动转换为所需的输出。使用“h”、“raw”、“html_safe”helper。有关更多信息,请看一看我使用了所有这些东西,但它不起作用。为什么我无法识别并尝试此:CGI::unescapeHTML(str)
 SUBJECT_LINE = { '&amp;' => '&',  '&gt;' => '>',   '&lt;' => '<', '&quot;' => '"' }