nullify_empty 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: '0459d74924231eed6419005c311ce8f2b196a7dd'
4
- data.tar.gz: 0fc1c50cfe4d7489fe7be439521c53325905d747
3
+ metadata.gz: b1cd0566cb64431a07fc94a4040fbf936ccc6dad
4
+ data.tar.gz: 6db5506decdafe3eff4a44fb792b50ab37838336
5
5
  SHA512:
6
- metadata.gz: 49fec594d8545501ddfb798b36d5b899340f27ee20766421676aa00ea9b0134047917b34a338ddb33d687657aab909e043a7cd87e92875d3f7772bd09b1b2747
7
- data.tar.gz: 140cb8a4966a48a33b25af469a2f51c8b48cb5230cf12714b4fe4327a6fb1e149641f0e688d1002650d00961efcb1e4d181e349f71fd3ec083c6a90d0f696dc2
6
+ metadata.gz: 8f0cf076c473576bc9d8ea86de3795d202a4dedbebc1979ad4ada9f655e1e6e825379c4391dce3015e25a71646bb78c9783bd9bd1aa4c822b3b3534ff25b46b8
7
+ data.tar.gz: 3c3600588a6c07b05aa7c5674eb2d59551e6ba59bbf069e188e9bea6125e5e29d43cb6cdb83f478d1ae00433680c6a79eea6590ffc499ad63087d5063b287c9f
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # NullifyEmpty
2
2
 
3
- This gem allows to store string or text attributes as NULL in DB if they have empty values.
3
+ This gem allows to store string or text Rails model attributes as NULL in DB when they have empty values.
4
4
  It is very useful when you need to avoid `""` values coming from blank form inputs or anywhere else to be stored in DB.
5
5
 
6
6
  Having empty values in DB is not allowed when there is unique constraint on the column or uniqueness validation on the field, while presence of the values is not required. Unique constraint ignores nulls in most DBMS.
@@ -51,7 +51,7 @@ user.email # => nil
51
51
 
52
52
  ## Contributing
53
53
 
54
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/nullify_empty. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
54
+ Bug reports and pull requests are welcome on GitHub at https://github.com/chumakoff/nullify_empty. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
55
55
 
56
56
  ## License
57
57
 
@@ -1,6 +1,8 @@
1
1
  module NullifyEmpty
2
2
  module ActiveRecordExtension
3
3
  def nullify_empty(*attr_names)
4
+ return unless connection.table_exists? table_name
5
+
4
6
  attr_names.each do |attr_name|
5
7
  original_type_klass = attribute_types[attr_name.to_s].class
6
8
 
@@ -1,3 +1,3 @@
1
1
  module NullifyEmpty
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nullify_empty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Chumakov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-31 00:00:00.000000000 Z
11
+ date: 2017-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord