An attribute sanitizer (ruby 1.9) based on the sanitize gem by rgrove ( Currently still dependant on active support, this requirement will be removed in the near future.


Add this line to your application's Gemfile:

gem 'clean_room'

And then execute:

$ bundle

Or install it yourself as:

$ gem install clean_room


CleanRoom accepts any attributes for which readers and writers are available. The default is to sanitize and not allow any html in the field. Other settings can be configured with "allow" (see below). Allow accepts:

  • normal (or not set): no html
  • strict: no html + no characters except a-zA-Z0-9 and spaces. You can pass 'character_class' to specify your own character class of allowed characters
  • simple_html: allow the tags as by Sanitize::Config::BASIC
  • html: allow the tags as by Sanitize::Config::RELAXED

    class SanitizedAttributes attr_accessor :normal, :strict, :very_strict, :simple_html, :html

    sanitize_attribute :normal
    sanitize_attribute :strict, allow: :strict, character_class: "a-z"
    sanitize_attribute :simple_html, allow: :simple_html
    sanitize_attribute :html, allow: :html



  1. Please fork it;
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
  6. Many thanks!