Strips spaces and empty strings from model attributes.
Ruby
Switch branches/tags
Nothing to show
Latest commit 3a6cd5d Dec 29, 2016 @thomasfedb Simplify README
Permalink
Failed to load latest commit information.
gemfiles Remove lockfiles Dec 29, 2016
lib Effective rewrite Dec 29, 2016
spec Effective rewrite Dec 29, 2016
.gitignore Remove lockfiles Dec 29, 2016
.ruby-gemset Effective rewrite Dec 29, 2016
.ruby-version Effective rewrite Dec 29, 2016
.travis.yml Effective rewrite Dec 29, 2016
Appraisals Effective rewrite Dec 29, 2016
Gemfile Effective rewrite Dec 29, 2016
LICENSE license & readme Dec 30, 2010
README.md Simplify README Dec 29, 2016
Rakefile Effective rewrite Dec 29, 2016
attr_cleaner.gemspec Update homepage to GitHub Dec 29, 2016

README.md

AttrCleaner

Cleans up your model attributes. Strips leading and trailing space, and turns empty strings into nil.

Tested against Rails 4.2 and 5.0.

Travis CI

Install

If you're using Rails with ActiveRecord all you need to do is:

gem "attr_cleaner"

Usage

Simply pass a list of attributes that you want to clean:

attr_cleaner :title, :body

Child models will inherit the attribute list from their parent by default.

Other ORMs

AttrCleaner will also work with any ORM that writes attributes via a method called write_attribute.

To get AttrCleaner working with your ORM just include it into your models:

include AttrCleaner::Model

Copyright

Copyright © 2010 Thomas Drake-Brockman