Skip to content

Sanitize gem bridge and helpers for Rails Applications

Notifications You must be signed in to change notification settings

earnold/sanitize-rails

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sanitize-Rails - sanitize .. on Rails.

Installation

Gemfile:

gem 'sanitize-rails'

Configuration

config/initializers/sanitizer.rb:

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

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.x under Ruby 1.8 and 1.9.

Have fun.

About

Sanitize gem bridge and helpers for Rails Applications

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%