⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
MyCyma
All Projects
MyCyma
Overview
Activity
Issues
Repository
Download (302 Bytes)
Statistics
| Branch:
master
| Tag:
0.2.0
| Revision:
root
/
vendor
/
plugins
/
empty_fields_to_null
/
lib
/
empty_fields_to_null.rb
@ b689e231
View
History
Annotate
module
EmptyFieldsToNull
def
self
.
included
(
base
)
base
.
class_eval
do
before_validation
{
|
model
|
model
.
empty_fields_to_null
}
end
end
def
empty_fields_to_null
attributes
.
each
do
|
key
,
value
|
self
[
key
]
=
nil
if
value
.
kind_of?
(
String
)
and
value
.
length
==
0
end
end
end
(1-1/1)
Loading...