No commit activity in last 3 years
No release in over 3 years
Blankable attribtes for ActiveRecord model'
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 4.2.3
~> 1.10
~> 3.3.0
~> 10.0
~> 3.3.0
~> 1.3.10
 Project Readme

BlankAttributes

Blankable attributes for the ActiveRecord model.

Installation

Add this line to your application's Gemfile:

gem 'blank_attributes'

And then execute:

$ bundle

Or install it yourself as:

$ gem install blank_attributes

Usage

class User < ActiveRecord::Base
  blank_attributes :name, :email
end

And use it:

user = User.new(name: '', email: ' ', token: ' ')
user.valid?
user.name # => nil
user.email # => nil
user.token # => " "

For preparing values there is used the before_valid callback.

Support Types

  • String
"" # => nil
" " # => nil
  • Array
[""] # => []
[" "] # => []
["", 1] # => [1]

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/blank_attributes.

License

The gem is available as open source under the terms of the MIT License.