0.0
No release in over a year
A gem to help sanitize input for any Rails model by providing a `sanitizable` concern
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

Sanitizable

Gem Version

Sanitizable is a Ruby gem that provides a simple way to perform HTML sanitization on attributes in ActiveRecord models.

Installation

Add this line to your application's Gemfile:

gem 'sanitizable'

And then execute:

bundle install

Or install it yourself as:

gem install sanitizable

Usage

To use Sanitizable in your ActiveRecord model, simply include the Sanitizable module and call the sanitizable class method to specify the attributes to sanitize.

class MyModel < ActiveRecord::Base
  include Sanitizable
  sanitizable :attribute_1, :attribute_2
end

This will automatically sanitize the specified attributes whenever the model is saved. Here is an example sanitization :

my_object.attribute_1 = "<b>Bold</b> no more!  <a href='more.html'>See more here</a>..."
my_object.save

my_object.attribute_1
# => Bold no more!  See more here..

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/Logora/sanitizable.

License

The gem is available as open source under the terms of the MIT License.