Plugins - StripAttributes
Add to favoritesStripAttributes
StripAttributes is a Rails plugin that automatically strips all ActiveRecord model attributes of leading and trailing whitespace before validation. If the attribute is blank, it strips the value to nil.
It works by adding a before_validation hook to the record. By default, all attributes are stripped of whitespace, but :only and :except options can be used to limit which attributes are stripped. Both options accept a single attribute (:only => :field) or arrays of attributes (:except => [:field1, :field2, :field3]).
Examples
class DrunkPokerPlayer < ActiveRecord::Base
strip_attributes!
end
class SoberPokerPlayer < ActiveRecord::Base
strip_attributes! :except => :boxers
end
class ConservativePokerPlayer < ActiveRecord::Base
strip_attributes! :only => [:shoe, :sock, :glove]
end
http://stripattributes.rubyforge.org/
git://github.com/rmm5t/strip_attributes.git
Rails' (MIT)
Model
