views:

224

answers:

2

Is there anything like sanitize for controllers?

thanks

+2  A: 

The way I do this is as follows:

# in application_controller.rb
def helpers
  Helper.instance
end

class Helper
  include ActionView::Helpers::TextHelper
  include ActionView::Helpers::SanitizeHelper
end

# in your controller
def index 
  @message = "Sanitized #{helpers.sanitize(...)}"
end

This namespaces your helpers in the controller, kind of, by extending an inner class. I hope this helps!

jonnii
btw, in future you should try to add more info to your question.
jonnii
I get the following error: `undefined method `instance' for ApplicationController::Helper:Class` What might be the problem?
Shripad K