Skip to content
TrimSpacesFor gem removes leading and trailing white spaces from the AR attribute values.
Ruby JavaScript
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
lib
spec
.gitignore
.rspec
CHANGELOG.md
Gemfile
Guardfile
MIT-LICENSE
README.md
Rakefile
trim_spaces_for.gemspec

README.md

TrimSpacesFor

TrimSpacesFor gem removes leading and trailing white spaces from the AR attribute values. That corresponds to the full-width space.

Installing

gem install trim_spaces_for

Usage

class Article < ActiveRecord::Base
  trim_spaces_for :title
end

> obj = Article.new
> obj.title = "  Article Title  "
> obj.save  #=> true
> obj.title  #=> "Article Title"

class User < ActiveRecord::Base
  trim_spaces_for :age
  validates :age, :numericality => {:only_integer => true}
end

> obj = User.new
> obj.age = " 23" # full-width space
> obj.save  #=> true
> obj.age #=> 23

This project rocks and uses MIT-LICENSE.

Something went wrong with that request. Please try again.