Registry / database / strip-attributes

strip-attributes

JSON →
library2.0.1rbrubygemsunverified

StripAttributes automatically strips all ActiveRecord model attributes of leading and trailing whitespace before validation. If the attribute is blank, it strips the value to nil.

gem install strip_attributes
INSTALL
IMPORT
SIG · STRIP-ATTRIBUTES
S
strip-attributes
databaserubyv2.0.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

StripAttributes
require 'strip_attributes'

Automatically strip whitespace from ActiveRecord attributes

require 'strip_attributes' class User < ActiveRecord::Base strip_attributes end user = User.new(name: ' John ') user.valid? puts user.name.inspect
Debug
Known issues
gotchaOnly works with ActiveRecord models; not for plain Ruby objects
fix
Use only within ActiveRecord::Base subclasses
affects: >= 0.0.0
gotchaStrips blank attributes to nil, which may change behavior if you expect empty strings
fix
Set allow_blank: false to keep empty strings
affects: >= 1.0.0
Upgrade
Version history
2.0.1latest on RubyGems
Audit
Dependencies

No dependency data recorded yet.

Agent activity
30 hits · last 30 days
node
26
OpenAI (training)
1
Resources
strip-attributes — gem install strip-attributes · libregistry