handy_generators 0.1.2 → 0.1.8
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/Gemfile.lock +1 -1
- data/README.md +39 -4
- data/lib/edit_links_helper/USAGE +14 -0
- data/lib/{generators → edit_links_helper}/edit_links_helper_generator.rb +1 -1
- data/lib/{generators/templates/edit_delete_links → edit_links_helper/templates}/edit_delete_links_helper.template +0 -0
- data/lib/{generators/templates/edit_delete_links → edit_links_helper/templates}/edit_delete_links_partial.template +0 -0
- data/lib/{generators/templates/edit_delete_links → edit_links_helper/templates}/edit_delete_links_partial_no_pundit.template +0 -0
- data/lib/handy_generators.rb +1 -1
- data/lib/handy_generators/version.rb +1 -1
- metadata +7 -7
- data/lib/generators/USAGE +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7d113f211bbdd551a0fd23fec01458efd1d89b4499716f9680c9c90dffa25a1
|
4
|
+
data.tar.gz: 8db9774519f008564b2416c58dfea6941a1d687eb4bb0fa4e7a30647e385d0d9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1fc413a078fd5f613c4223b8972b7d6c37e4782eefb59b4dbd01c7e941d0f63ac3958188d8a8aab19596febf91b66898822128d544785f6a720f09da08ce233
|
7
|
+
data.tar.gz: e1adc6a24e7cd2573a2c23299558546fb6008803744e87fe974256da11033f5eb7c66dbeb8b0b14b284f15cc40e0fd278c187a716e019a48f8c0d39918f8dc49
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# HandyGenerators
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
This gem adds some handy generators to your Rails app.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
@@ -22,7 +20,44 @@ Or install it yourself as:
|
|
22
20
|
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
|
23
|
+
### Edit Links Helper
|
24
|
+
|
25
|
+
#### Generators
|
26
|
+
|
27
|
+
```
|
28
|
+
rails generate handy_generators:edit_links_helper
|
29
|
+
```
|
30
|
+
|
31
|
+
This generator will add a helper and a partial for displaying edit and
|
32
|
+
delete links for a record. This uses pundit by default to check
|
33
|
+
whether a user should be able to edit and/or delete the record before
|
34
|
+
displaying the link. If you'd like to always display these links when
|
35
|
+
you use the helper in the view or handle the logic yourself, simply
|
36
|
+
add --pundit false to your command.
|
37
|
+
|
38
|
+
```
|
39
|
+
rails generate handy_generators:edit_links_helper --pundit false
|
40
|
+
```
|
41
|
+
|
42
|
+
#### Helpers
|
43
|
+
|
44
|
+
`edit_links(record:, edit_classes: '', delete_classes: '')`
|
45
|
+
|
46
|
+
The `edit_links` helper receives three parameters `record`, `edit_classes`,
|
47
|
+
and `delete_classes`. Record is the only required parameter,
|
48
|
+
`edit_classes` and `delete_classes` will be empty by default, if you'd
|
49
|
+
like to add classes you can pass them as parameters to the helper. The
|
50
|
+
default helper uses pundit, and it will check if the logged in user has
|
51
|
+
permission to edit or delete the record before displaying the links. If
|
52
|
+
not, it will display the edit or delete links to all users.
|
53
|
+
|
54
|
+
`edit_record_link(record:, classes: '')`
|
55
|
+
|
56
|
+
The `edit_record_link` helper will just display an edit link, it won't check if the user has permission before displaying the link. Classes that you pass in as a parameter will be applied to the link.
|
57
|
+
|
58
|
+
`delete_record_link(record:, classes: '')`
|
59
|
+
|
60
|
+
The `delete_record_link` helper will display just display a delete link, with a confirm. It also doesn't check if the user has permission before displaying the link. Classes that you pass in as a parameter will be applied to the link.
|
26
61
|
|
27
62
|
## Development
|
28
63
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Description:
|
2
|
+
This generator will add a helper and a partial for displaying edit and
|
3
|
+
delete links for a record. This uses pundit by default to check
|
4
|
+
whether a user should be able to edit and/or delete the record before
|
5
|
+
displaying the link. If you'd like to always display these links when
|
6
|
+
you use the helper in the view or handle the logic yourself, simply
|
7
|
+
add --pundit false to your command.
|
8
|
+
|
9
|
+
Example:
|
10
|
+
rails generate edit_links_helper add [--pundit false]
|
11
|
+
|
12
|
+
This will create:
|
13
|
+
app/helpers/edit_delete_links_helper.rb
|
14
|
+
app/views/shared/_edit_delete_links.html.erb
|
File without changes
|
File without changes
|
File without changes
|
data/lib/handy_generators.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: handy_generators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DakotaLMartinez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -99,11 +99,11 @@ files:
|
|
99
99
|
- bin/console
|
100
100
|
- bin/setup
|
101
101
|
- handy_generators.gemspec
|
102
|
-
- lib/
|
103
|
-
- lib/
|
104
|
-
- lib/
|
105
|
-
- lib/
|
106
|
-
- lib/
|
102
|
+
- lib/edit_links_helper/USAGE
|
103
|
+
- lib/edit_links_helper/edit_links_helper_generator.rb
|
104
|
+
- lib/edit_links_helper/templates/edit_delete_links_helper.template
|
105
|
+
- lib/edit_links_helper/templates/edit_delete_links_partial.template
|
106
|
+
- lib/edit_links_helper/templates/edit_delete_links_partial_no_pundit.template
|
107
107
|
- lib/handy_generators.rb
|
108
108
|
- lib/handy_generators/version.rb
|
109
109
|
homepage: https://github.com/DakotaLMartinez/handy_generators
|
data/lib/generators/USAGE
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
Description:
|
2
|
-
This generator will add a helper and a partial for displaying edit and delete links
|
3
|
-
for a record. This uses pundit by default to check whether a user should be able to
|
4
|
-
edit and/or delete the record before displaying the link. If you'd like to always
|
5
|
-
display these links when you use the helper in the view or handle the logic yourself, simply add --pundit false to your command.
|
6
|
-
|
7
|
-
Example:
|
8
|
-
rails generate edit_links_helper add [--pundit false]
|
9
|
-
|
10
|
-
This will create:
|
11
|
-
app/helpers/edit_delete_links_helper.rb
|
12
|
-
app/views/shared/_edit_delete_links.html.erb
|