Is there something like sanitize for controllers?

Is there something like sanitize for controllers?

+3
source share
2 answers

How do i do this:

# 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

These names put your helpers on the controller, for example, by extending the inner class. Hope this helps!

+3
source

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
+4
source

Source: https://habr.com/ru/post/1733952/


All Articles