Using helpers in model: how do I include helper dependencies?

后端 未结 6 896
伪装坚强ぢ
伪装坚强ぢ 2020-11-27 13:37

I\'m writing a model that handles user input from a text area. Following the advice from http://blog.caboo.se/articles/2008/8/25/sanitize-your-users-html-input, I\'m cleani

6条回答
  •  迷失自我
    2020-11-27 14:35

    This gives you just the helper method without the side effects of loading every ActionView::Helpers method into your model:

    ActionController::Base.helpers.sanitize(str)
    

提交回复
热议问题