I have a custom error proc that gets initialised in application.rb:
config.action_view.field_error_proc = Proc.new do |html_tag, object|
error_msg = object.error_message.join(", ")
"<span class='field_with_errors' data-error='#{error_msg}'>#{html_tag}</span>".html_safe
end
I would like to escape javascript, so I modify it:
config.action_view.field_error_proc = Proc.new do |html_tag, object|
error_msg = object.error_message.join(", ")
"<span class='field_with_errors' data-error='#{escape_javascript(error_msg)}'>#{html_tag}</span>".html_safe
end
However I get the following error:
undefined method `escape_javascript' for #<MyApp::Application:0x00000006edd2e8>
I'm using rails 3.0
Any tips would be greatly appreciated.