Browse the Ruby on Rails Community.

You are here: Browse Railsplugins Acts As Sanitizedstr

Acts As Sanitizedstr

= ActsAsSanitizedstr

ActsAsSanitizedstr is a quick and simple string sanitizer plugin. It turns all empty strings into NULLs and strips leading and trailing whitespaces before the data are saved into the database.

ActsAsSanitizedstr does NOT escape apostrophes and backslashes since this is (supposedly) automatically done by Ruby. However, these functionalities can also be easily added by un-commenting the following lines of code from acts_as_sanitizedstr.rb:

self[field.to_sym] = self[field.to_sym].gsub!(/’/, ”’’”)

self[field.to_sym] = self[field.to_sym].gsub!(/\/, ”\\”)

== Instructions

Simply add a class method to your ActiveRecord class definition as follows:

acts_as_sanitizedstr

For example,

class Region < ActiveRecord::Base
  validates_presence_of :name
  acts_as_sanitizedstr      
end

NOTE: This description has been extracted from the Plugin README and so the formatting may need updating to make browser friendly

Users


See all details


Membership

+ Join this railsplugin

Record Maintainer

'None'