strong_form 0.0.2 → 0.0.3
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/CHANGELOG.md +26 -0
- data/lib/strong_form/form.rb +5 -5
- data/lib/strong_form/version.rb +1 -1
- data/spec/dummy/app/controllers/base_controller.rb +10 -0
- data/spec/dummy/log/test.log +5493 -0
- data/spec/examples.txt +53 -53
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a4b92dbd144d13249f5a77baf5ed520b56a41f2
|
4
|
+
data.tar.gz: 7111499d4467203c84232c2d29926b83482b3864
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f12718f5019d565731035884ceaf08913945306e262bb42f7e5b12fbb1417d65157431c3cf521f1219898e1a15496fe8558bcaa19c146f50cf4defabdf682fce
|
7
|
+
data.tar.gz: 029cca5e49b51bf56faff61a8f30e0785fcd25018ebb4084e1a8b7e9d1d6f649c54f006ea55eff0f934b79f54aa167e98e61dd904467c95f659e25abd2362d0b
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## master
|
4
|
+
|
5
|
+
## 0.0.3
|
6
|
+
|
7
|
+
### Bugs fixed
|
8
|
+
|
9
|
+
* Rename `permitted_attributes` to `_strong_form_permitted_attributes` because
|
10
|
+
it would get overwritten if there is a helper method `permitted_attributes` in
|
11
|
+
controller
|
12
|
+
|
13
|
+
### Build system
|
14
|
+
|
15
|
+
* Add CHANGELOG.md to gemspec
|
16
|
+
|
17
|
+
## 0.0.2
|
18
|
+
|
19
|
+
### Bugs fixed
|
20
|
+
|
21
|
+
* Allow to use non-block syntax for nested form `link_to_add`
|
22
|
+
([5ddc396d5bc03fdef8b4b69b4efcdd0333327ae2](https://github.com/Stellenticket/strong_form/commit/5ddc396d5bc03fdef8b4b69b4efcdd0333327ae2))
|
23
|
+
|
24
|
+
## 0.0.1
|
25
|
+
|
26
|
+
Initial release
|
data/lib/strong_form/form.rb
CHANGED
@@ -3,17 +3,17 @@ module ActionView
|
|
3
3
|
module FormHelper
|
4
4
|
alias_method :orig_form_for, :form_for
|
5
5
|
|
6
|
-
attr_accessor :
|
6
|
+
attr_accessor :_strong_form_permitted_attributes
|
7
7
|
|
8
8
|
def form_for(record, options = {}, &block)
|
9
9
|
# explicilty passed
|
10
10
|
if options.key?(:permitted_attributes)
|
11
|
-
self.
|
11
|
+
self._strong_form_permitted_attributes = options.delete(:permitted_attributes)
|
12
12
|
record.permitted_attributes =
|
13
|
-
|
13
|
+
_strong_form_permitted_attributes if record.respond_to?(:permitted_attributes=)
|
14
14
|
# assigned to object
|
15
15
|
elsif record.respond_to?(:permitted_attributes)
|
16
|
-
self.
|
16
|
+
self._strong_form_permitted_attributes = record.permitted_attributes
|
17
17
|
end
|
18
18
|
|
19
19
|
orig_form_for(record, options, &block)
|
@@ -46,7 +46,7 @@ module ActionView
|
|
46
46
|
def fields_for(record_name, record_object = nil, options = {}, &block)
|
47
47
|
assign_child_permitted_attributes!(
|
48
48
|
record_name, record_object, options[:parent_builder].object.permitted_attributes
|
49
|
-
) if
|
49
|
+
) if _strong_form_permitted_attributes && record_object.respond_to?(:permitted_attributes=) && record_object.permitted_attributes.nil?
|
50
50
|
|
51
51
|
builder = instantiate_builder(record_name, record_object, options)
|
52
52
|
capture(builder, &block)
|
data/lib/strong_form/version.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
class BaseController < ApplicationController
|
2
|
+
helper_method :permitted_attributes
|
3
|
+
|
2
4
|
def basic_form
|
3
5
|
@user = User.new
|
4
6
|
end
|
@@ -19,4 +21,12 @@ class BaseController < ApplicationController
|
|
19
21
|
@user = User.new
|
20
22
|
@user.addresses.build
|
21
23
|
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def permitted_attributes
|
28
|
+
{
|
29
|
+
bla: :blub
|
30
|
+
}
|
31
|
+
end
|
22
32
|
end
|