Replace Entities¶ ↑
If you import data from confused sources you may end up with HTMLish entites littering your model data. I’m looking at you ®
If you don’t want them, then replace them with the appropriate UTF-8 character before they make it into your database.
class Product < ActiveRecord::Base replace_entities! end class Product < ActiveRecord::Base replace_entities!, :except => :title end class Product < ActiveRecord::Base replace_entities!, :only => :description end
On rails 2.3
* gem install strip_control_chars * add the following to your environment.rb config.gem 'replace_entities', version => "<2.0"
On rails 3
* gem install strip_control_chars * add the following to your Gemfile gem 'replace_entities', ">=2.0"
On rails 2.x you must use version 1.x of this gem. On rails 3.x you must use version 2.x of this gem.
The entities are replaced with UTF-8 characters. If you’re not expecting UTF-8 data, you may end up with invalid strings.
This plugin is essentially a fork of the strip attributes plugin, released under the MIT License by Ryan McGeary.
Copyright © 2007-2008 Ryan McGeary released under the MIT license Copyright © 2010 James Healy released under the MIT license