Is there anything like sanitize for开发者_如何学JAVA controllers?
via: http://www.adaruby.com/2009/12/16/how-to-use-actionview-helpers-in-your-rails-controller/
I think the Helper class should be:
class Helper
include Singleton
include ActionView::Helpers::TextHelper
end
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!
精彩评论