this is a way that i am passing subject line to a methods
@subject_text = html_subject(@customer_alert.alert.name)
@subject_text = html_sub(@customer_alert.alert.name)
and this are the two methods where i wanna replace all special character
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(/</,'<')
end
if s.gsub(/"/,'"')
end
s
end
end
and constant defined in model is
SUBJECT_LINE = { '&' => '&', '>' => '>', '<' => '<', '"' => '"' }
but first methods call all special character is replaced by null and second method call not returning any value