on_form 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.md +14 -6
- data/README.md +3 -1
- data/lib/on_form/saving.rb +7 -1
- data/lib/on_form/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef390c085a64b23daf7e8439918a5db0c33d351f
|
4
|
+
data.tar.gz: fb98c2b228bfb52f2a732a09d513afa7643f840e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb5bf8f542ea1243dfe9f232e7cf8fe603b8ab908142d1a657c2c99bd38c41c8c125486a356815881192f6c776f5705e90ee12a9e5d56e4034da710906c3f8d4
|
7
|
+
data.tar.gz: 6dcf2fa5591a255808602edba8399b0625d36c63d6fd9cd65e8c8e0dce24fda3b51c2e1ec5f134501a94e11451c587cc3ed45f8b8e4a9ee344784e635d9d947d
|
data/CHANGES.md
CHANGED
@@ -1,15 +1,23 @@
|
|
1
1
|
Changelog
|
2
2
|
=========
|
3
3
|
|
4
|
-
2.
|
5
|
-
|
4
|
+
2.2.0
|
5
|
+
-----
|
6
|
+
* Remove the previously existing transaction caveat around model-less saves.
|
7
|
+
|
8
|
+
2.1.0
|
9
|
+
-----
|
10
|
+
* Implement support for introducing typed "artificial" attributes.
|
11
|
+
|
12
|
+
2.0.1
|
13
|
+
-----
|
6
14
|
* Fix regressions in support for Rails 4.2.
|
7
15
|
* Support some additional attribute methods such as `*_was` and `*_changed?`.
|
8
16
|
|
9
|
-
2.
|
10
|
-
|
17
|
+
2.0.0
|
18
|
+
-----
|
11
19
|
* New expose syntax to support prefix:, suffix:, and as: options.
|
12
20
|
|
13
|
-
1.
|
14
|
-
|
21
|
+
1.0.0
|
22
|
+
-----
|
15
23
|
* First public release.
|
data/README.md
CHANGED
@@ -228,7 +228,7 @@ end
|
|
228
228
|
|
229
229
|
### Model-less forms
|
230
230
|
|
231
|
-
Taking this one step further, you can define forms which have _no_ exposed model attributes.
|
231
|
+
Taking this one step further, you can define forms which have _no_ exposed model attributes.
|
232
232
|
|
233
233
|
To actually perform a data change in response to the form submission, you can add a `before_save` or `after_save` callback and from there call your existing model code or service objects. It's best to keep the code in the form object to just the bits specific to the form - try not to put your business logic in your form objects!
|
234
234
|
|
@@ -264,6 +264,8 @@ class ChangePasswordForm < OnForm::Form
|
|
264
264
|
end
|
265
265
|
```
|
266
266
|
|
267
|
+
Note that when you have no exposed models, OnForm will still wrap the save process in a database transaction for you, using `ActiveRecord::Base.transaction`. If you have multiple database connections, you may need to start transactions on the other connections yourself.
|
268
|
+
|
267
269
|
### Reusing and extending forms
|
268
270
|
|
269
271
|
You can descend form classes from other form classes and expose additional models or additional attributes on existing models.
|
data/lib/on_form/saving.rb
CHANGED
@@ -5,7 +5,13 @@ module OnForm
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def transaction(&block)
|
8
|
-
|
8
|
+
backing_models = backing_model_instances
|
9
|
+
|
10
|
+
if backing_models.empty?
|
11
|
+
with_transactions([ActiveRecord::Base], &block)
|
12
|
+
else
|
13
|
+
with_transactions(backing_model_instances, &block)
|
14
|
+
end
|
9
15
|
end
|
10
16
|
|
11
17
|
def invalid?
|
data/lib/on_form/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: on_form
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Will Bryant
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|