superuser 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/superuser/USAGE +16 -3
- data/lib/generators/superuser/superuser_generator.rb +2 -2
- data/lib/generators/superuser/templates/controller_template.rb +5 -5
- data/lib/generators/superuser/templates/views/index.html.erb +1 -1
- data/lib/superuser/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37ba17de48a89db27bfd4cc1a10b09224f357abe34af8fd460b67b16335ed6e8
|
4
|
+
data.tar.gz: 819e3904403516ea5e17dc57262a4feef66c55bee5c97df0c4e23e855330ebc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2916b5fb284d9d7d7a0564a6cbf795dcfdce93bcff8f0d2bc2c8da34d5ca44de67770c1c33a5b3ce34fb66821cb4320afd44d7970213bafd8e464e5da40bbdca
|
7
|
+
data.tar.gz: 2df66f5f8edb5d244d6d0a069559f7a42d14f52f77f51e8d0d62b8157698bf090a271e73add5abf2524df0c5449b78356f355c5fde6b3e6ee7db5c180e2a2fd8
|
@@ -1,8 +1,21 @@
|
|
1
1
|
Description:
|
2
|
-
|
2
|
+
Generate scaffolding for you rails admin area using the command "rails g superuser name_of_your_resource"
|
3
3
|
|
4
4
|
Example:
|
5
|
-
rails generate superuser
|
5
|
+
rails generate superuser users
|
6
6
|
|
7
7
|
This will create:
|
8
|
-
|
8
|
+
controllers/superuser/users_controller.rb
|
9
|
+
views/superuser/index.html.erb
|
10
|
+
views/superuser/new.html.erb
|
11
|
+
views/superuser/show.html.erb
|
12
|
+
views/superuser/edit.html.erb
|
13
|
+
views/superuser/_form.html.erb
|
14
|
+
|
15
|
+
+ will create some base/shared files if they don't exists:
|
16
|
+
assets/javascripts/superuser/application.js
|
17
|
+
assets/stylesheets/superuser/application.scss
|
18
|
+
controllers/superuser/base_controller.rb
|
19
|
+
controllers/superuser/dashboard_controller.rb
|
20
|
+
views/layouts/superuser/application.html.erb
|
21
|
+
views/shared/_search.html.erb
|
@@ -5,7 +5,7 @@ class SuperuserGenerator < Rails::Generators::Base
|
|
5
5
|
attr_accessor :attributes
|
6
6
|
|
7
7
|
# NOTE: the order of the following methods is important!
|
8
|
-
|
8
|
+
|
9
9
|
def generate_css_file
|
10
10
|
|
11
11
|
if !File.exist?("app/assets/stylesheets/superuser/application.scss")
|
@@ -69,7 +69,7 @@ class SuperuserGenerator < Rails::Generators::Base
|
|
69
69
|
|
70
70
|
def generate_search_form
|
71
71
|
|
72
|
-
template "views/_search.html.erb", "app/views/shared/_search.html.erb"
|
72
|
+
template "views/_search.html.erb", "app/views/shared/superuser/_search.html.erb"
|
73
73
|
|
74
74
|
end
|
75
75
|
|
@@ -4,7 +4,7 @@ module Superuser
|
|
4
4
|
|
5
5
|
# List all the (only) actions so it won't be applied to user's custom actions
|
6
6
|
|
7
|
-
before_action :
|
7
|
+
before_action :set_<%= resource %>, only: [:show, :edit, :update, :destroy]
|
8
8
|
|
9
9
|
# GET /<%= resources %>
|
10
10
|
def index
|
@@ -41,7 +41,7 @@ module Superuser
|
|
41
41
|
# POST /<%= resources %>
|
42
42
|
def create
|
43
43
|
|
44
|
-
@<%= resource %> = <%= get_model %>.new(
|
44
|
+
@<%= resource %> = <%= get_model %>.new(<%= resource %>_params)
|
45
45
|
|
46
46
|
if @<%= resource %>.save
|
47
47
|
|
@@ -58,7 +58,7 @@ module Superuser
|
|
58
58
|
# PATCH/PUT /<%= resources %>/1
|
59
59
|
def update
|
60
60
|
|
61
|
-
if @<%= resource %>.update(
|
61
|
+
if @<%= resource %>.update(<%= resource %>_params)
|
62
62
|
|
63
63
|
redirect_to [:superuser, @<%= resource %>], notice: "<%= resource %> was successfully updated."
|
64
64
|
|
@@ -84,14 +84,14 @@ module Superuser
|
|
84
84
|
|
85
85
|
|
86
86
|
# Only allow a trusted parameter "white list" through.
|
87
|
-
def
|
87
|
+
def <%= resource %>_params
|
88
88
|
|
89
89
|
params.require(:<%= resource %>).permit(<%= editable_attributes.map { |a| ":" + a[:name] }.join(', ') %>)
|
90
90
|
|
91
91
|
end
|
92
92
|
|
93
93
|
|
94
|
-
def
|
94
|
+
def set_<%= resource %>
|
95
95
|
|
96
96
|
@<%= resource %> = <%= get_model %>.find(params[:id])
|
97
97
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<%#= without method_messing available as helper, it should be [main_app, :new, :superuser, @model.table_name.singularize] %>
|
4
4
|
<%= "<%= link_to 'Add new #{resource}', [:new, :superuser, :#{resource}], class: 'btn btn-info float-sm-right' %%>" %>
|
5
5
|
|
6
|
-
<%= "<%= render 'shared/search', obj: '#{resources}' %%>" %>
|
6
|
+
<%= "<%= render 'shared/superuser/search', obj: '#{resources}' %%>" %>
|
7
7
|
|
8
8
|
<div class="table-responsive">
|
9
9
|
|
data/lib/superuser/version.rb
CHANGED