An active record plugin for replacing HTML entities with UTF-8 characters
Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
MIT-LICENSE
README.rdoc
Rakefile
replace_entities.gemspec

README.rdoc

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.

Examples

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

Installation

  1. On rails 2.3

* gem install strip_control_chars
* add the following to your environment.rb

  config.gem 'replace_entities', version => "<2.0"
  1. On rails 3

* gem install strip_control_chars
* add the following to your Gemfile

  gem 'replace_entities', ">=2.0"

Compatibility

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.

Caveats

The entities are replaced with UTF-8 characters. If you're not expecting UTF-8 data, you may end up with invalid strings.

Credits

This plugin is essentially a fork of the strip attributes plugin, released under the MIT License by Ryan McGeary.

github.com/rmm5t/strip_attributes

License

Copyright © 2007-2008 Ryan McGeary released under the MIT license Copyright © 2010 James Healy released under the MIT license

en.wikipedia.org/wiki/MIT_License