ruby on rails - Using helpers in model: how do I include helper dependencies? -


I am writing a model that handles user input from a text field.

After the advice before, I'm using the first_valid callback before saving the database before cleaning the input in the model.

The relevant parts of my model look like this:

  Include ActionView: Helpers :: SyntaseHeller class post & lt; ActiveRecord :: Base {before_validation: clean_input ... protected def clean_input self.input = sanitize (self.input, tag = & gt;% w (biu)) and end  

, It does not work when I try to try and save a new post, I get the following error.

  Exclusive method # # for `white_list_sanitizer 'category: 0xdeadbeef & gt; Apparently, SanitizeHelper creates an example of HTML :: WhiteListSanitizer, but when I combine it in my model it can not get HTML :: WhiteListSenector. Why? What can I do about this to fix this?   

Just change the first line of this type:

Update: To use Rail 3: contains ActionView :: Helpers

.

  ActionController :: base.helpers.sanitize (str)  

goes to credit


Comments