Skip to content

mixr/white_list_model

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WhiteListModel

Instead of using white_list_helper in every view just use it as model before_filter! This way you don’t have to escape/whitelist user-input data in every place they appear, just filter it on save.

Usage

class News < ActiveRecord::Base
  white_list  # Filter all string or text fields with standard filter set
end

class News < ActiveRecord::Base
  white_list :only => [ :description ]  # Filter description field with standard filter set
end

Avalible parameters

:only => []          # Filter only included fields
:except => []        # Filter all string or text fields except included
:attributes => []    # Add specified attributes to allowed list
:bad_tags =>         # Add specified tags to completely trim
:protocols => []     # Add specified protocols to allowed list
:tags => []          # Add specified tags to allowed list
:profile => :default # Load specified profile. If no profile given then :default will be used. Avalible profiles :empty, :mini, :base, :web and :default

Profile will be used as template, and other options will be merged, so if you want options to be fully customized, use empty profile.

Copyright © 2008 Bernard Potocki, released under the MIT license

About

Instead of using white_list_helper in every view just use it as model before_filter!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%