webget_ramp 1.7.1.4 → 1.7.1.5

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
@@ -0,0 +1,22 @@
1
+
2
+ require 'active_record'
3
+
4
+ module ActiveRecord::SaveExtensions
5
+
6
+ # Save the record without validation, then reload it.
7
+ # If the record is valid then return true, otherwise raise RecordInvalid.
8
+ # This solves an issue we found with Rails associations not saving.
9
+ #
10
+ # By Andrew Carpenter (acarpen@wested.org)
11
+
12
+ def save_false_then_reload!
13
+ transaction do
14
+ save(false)
15
+ reload
16
+ valid? or raise ActiveRecord::RecordInvalid.new(self)
17
+ end
18
+ return true
19
+ end
20
+
21
+ end
22
+ ActiveRecord::Base.send(:include, ActiveRecord::SaveExtensions)
@@ -0,0 +1,7 @@
1
+ require 'test/unit'
2
+ require 'webget_ramp'
3
+ require 'active_record'
4
+
5
+ class SaveExtensionsText < Test::Unit::TestCase
6
+ end
7
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webget_ramp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1.4
4
+ version: 1.7.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - WebGet
@@ -48,6 +48,7 @@ files:
48
48
  - lib/webget_ramp.rb
49
49
  - lib/webget_ramp/active_record.rb
50
50
  - lib/webget_ramp/active_record/connection_adapters/abstract/schema_statements.rb
51
+ - lib/webget_ramp/active_record/save_extensions.rb
51
52
  - lib/webget_ramp/array.rb
52
53
  - lib/webget_ramp/csv.rb
53
54
  - lib/webget_ramp/date.rb
@@ -105,6 +106,7 @@ summary: WebGet ramp gem provides base extensions to ruby classes and rails clas
105
106
  test_files:
106
107
  - test/webget_ramp/active_record_test.rb
107
108
  - test/webget_ramp/active_record/connection_adapters/abstract/schema_statements_test.rb
109
+ - test/webget_ramp/active_record/save_extensions_test.rb
108
110
  - test/webget_ramp/array_test.rb
109
111
  - test/webget_ramp/csv_test.rb
110
112
  - test/webget_ramp/date_test.rb
metadata.gz.sig CHANGED
Binary file