Skip to content
Rails - Allows you to specify models that will always sanitize content before saving it to the database.
Ruby
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
spec
tasks
test
.gitignore
MIT-LICENSE
README
Rakefile
init.rb
install.rb
uninstall.rb

README

Sanitize Before Save
====================

'Sanitize Before Save' is a Ruby on Rails plugin.
It Allows you to specify models that will always sanitize content before saving it to the database.


Example
=======

Just put the following line ('sanitize_before_save') in your model : 

class Person < ActiveRecord::Base
  sanitize_before_save
end

and automaticaly all your model data stored in database as a String value will be sanitized before they will be saved (or updated).

@person = Person.create(:name => %(Mathieu Fosse<script type="text/javascript">alert('Hello !');</script>))
@person.name == "Mathieu Fosse"


Optionnaly you can add an except option to disabled sanitize process in some fields like that :

class Person < ActiveRecord::Base
  sanitize_before_save :except => :name
end

With this option, all Person model fields will be sanitized before they will be saved except for 'name' field. 



Copyright (c) 2008 Dante S. Regis, released under the MIT license
Something went wrong with that request. Please try again.