开发者

Is there anything like sanitize for controllers?

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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜