Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Sanitize gem bridge and helpers for Rails Applications

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 example
Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 Gemfile
Octocat-spinner-32 README.md
Octocat-spinner-32 Rakefile
Octocat-spinner-32 sanitize-rails.gemspec
README.md

Sanitize-Rails - sanitize .. on Rails. Build Status

Installation

Gemfile:

gem 'sanitize-rails', :require => 'sanitize/rails'

Configuration

config/initializers/sanitizer.rb:

Sanitize::Rails.configure(
  :elements    => [ ... ],
  :attribiutes => { ... },
  ...
)

There's an example in the example/ directory.

Usage

app/models/foo.rb:

sanitizes :field
sanitizes :some_other_field,  :on => :create
sanitizes :yet_another_field, :on => :save

ActionView sanitize helper is overriden to use the Sanitize gem - transparently.

Testing

Only Test::Unit for now - please write matchers and send a pull request :-)

test/test_helper:

Sanitize::Rails::TestHelpers.setup(self,
  :invalid => 'some <a>string',
  :valid   => 'some <a>string</a>'
)

your test:

assert_sanitizes(Model, :field, :some_other_field)

Compatibility

Tested with Rails 3.0 ~ 4.0 under Ruby 1.9 and 2.0.

License

MIT

Have fun!

Something went wrong with that request. Please try again.