Just change the first line as follows :
include ActionView::Helpers
that will make it works.
UPDATE: For Rails 3 use:
ActionController::Base.helpers.sanitize(str)
Credit goes to lornc’s answer
More Related Contents:
- Rails ActiveRecord methods in different places [closed]
- Is there a way to get a collection of all the Models in your Rails app?
- Rails :dependent => :destroy VS :dependent => :delete_all
- ActiveRecord.find(array_of_ids), preserving order
- Rails model without database
- How do I replace accented Latin characters in Ruby?
- Using Rails serialize to save hash to database
- Rails 3: Get Random Record
- Rails 5: ActiveRecord OR query
- How to handle Ruby on Rails error: “Please install the postgresql adapter: `gem install activerecord-postgresql-adapter'”
- Altering the primary key in Rails to be a string
- Rails find_or_create_by more than one attribute?
- LEFT OUTER joins in Rails 3
- How to test for (ActiveRecord) object equality
- Rails 3, has_one / has_many with lambda condition
- How do i work with two different databases in rails with active records?
- Rails ActiveRecord: Find All Users Except Current User
- How to use ActiveRecord in a ruby script outside Rails?
- Ruby on Rails – Access controller variable from model
- Regular expressions with validations in RoR 4
- What are the brackets [5.1] after ActiveRecord Migration and how does it work? [duplicate]
- Converting an array of objects to ActiveRecord::Relation
- How to implement Active Record inheritance in Ruby on Rails?
- Rails: Skinny Controller vs. Fat Model, or should I make my Controller Anorexic?
- Rails 3.1 limit user created objects
- Store the day of the week and time?
- Is there a way to avoid automatically updating Rails timestamp fields?
- Rails: Overriding ActiveRecord association method
- Rails Model has_many with multiple foreign_keys
- Rails Object Relationships and JSON Rendering