h(html_escape)はmodelでは使えないので
h()はhtml_escape()のaliasで,html_escape()はvendor/rails/actionpack/lib/action_view/base.rbにあると言うことなので,modelで使う方法を模索して頓挫.仕方ないので,methodをmodelのprivate methodとして実装しました.こんな感じ.
# for sanitize def sanitize( html ) html_escapes = { '&' => '&', '"' => '"', '>' => '>', '<' => '<' } html.to_s.gsub(/[&\"><]/) { |special| html_escapes[special] } end