action_crud 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/action_crud/controller.rb +17 -6
- data/lib/action_crud/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: 2bec677719c37b510e60fd122623b1b5ca4bb7f1
|
4
|
+
data.tar.gz: ee0acbd7660e0b4ce61f3aba0e8df935d63468bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5cd7315126fe152cf5575ab417fd73ea357622d403b43089e255a85fa289d5d45865c7c8a4f3cc1ec050c6c9e526312b5c6efa350621972b4d0c5991b11854c3
|
7
|
+
data.tar.gz: c7362315dbaf55802ab75f05f75220672e434508b5d6a082b0738c5d1f2c62dbaa54eb9ea84212e0d10baf69062206fa970b15aafd404a15ae4597c24194a352
|
@@ -16,7 +16,6 @@ module ActionCrud
|
|
16
16
|
|
17
17
|
# Set class attributes
|
18
18
|
set_model_name
|
19
|
-
set_model_class
|
20
19
|
set_index_scope
|
21
20
|
|
22
21
|
# Action callbacks
|
@@ -27,7 +26,8 @@ module ActionCrud
|
|
27
26
|
class_methods do
|
28
27
|
# Set permitted parameters
|
29
28
|
def permit_params(options={})
|
30
|
-
|
29
|
+
attribs = model_class.try(:attribute_names).to_a
|
30
|
+
default = { only: attribs, except: [], also: [], array: [], hash: [] }
|
31
31
|
options = Hash[default.merge(options).map { |k, v| [k, Array(v).map(&:to_sym)] }]
|
32
32
|
permit = options.except(:except).values.flatten.uniq
|
33
33
|
|
@@ -40,12 +40,16 @@ module ActionCrud
|
|
40
40
|
|
41
41
|
# Set model name
|
42
42
|
def set_model_name(name=nil)
|
43
|
-
name = name ||
|
43
|
+
name = name || _guess_controller_model
|
44
44
|
name = name.constantize if name.is_a? String
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
46
|
+
unless name.nil?
|
47
|
+
self.model_name = name.model_name
|
48
|
+
self.instance_name = model_name.singular
|
49
|
+
self.collection_name = model_name.plural
|
50
|
+
|
51
|
+
set_model_class
|
52
|
+
end
|
49
53
|
end
|
50
54
|
|
51
55
|
# Set model class
|
@@ -58,6 +62,13 @@ module ActionCrud
|
|
58
62
|
def set_index_scope(scope='all')
|
59
63
|
self.index_scope = scope.to_sym
|
60
64
|
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def _guess_controller_model
|
69
|
+
controller_name.classify.safe_constantize ||
|
70
|
+
name.sub(/controller/i, '').classify.safe_constantize
|
71
|
+
end
|
61
72
|
end
|
62
73
|
|
63
74
|
# GET /model
|
data/lib/action_crud/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: action_crud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonian Guveli
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|