administrated_scaffold 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/USAGE +12 -0
- data/administrated_scaffold_generator.rb +214 -0
- data/templates/controller.rb +16 -0
- data/templates/controller_admin.rb +59 -0
- data/templates/form.rhtml +3 -0
- data/templates/form_scaffolding.rhtml +1 -0
- data/templates/functional_test.rb +98 -0
- data/templates/helper.rb +2 -0
- data/templates/helper_admin.rb +2 -0
- data/templates/layout.rhtml +13 -0
- data/templates/style.css +74 -0
- data/templates/view_edit.rhtml +9 -0
- data/templates/view_list.rhtml +27 -0
- data/templates/view_list_public.rhtml +27 -0
- data/templates/view_new.rhtml +8 -0
- data/templates/view_show.rhtml +8 -0
- data/templates/view_show_public.rhtml +8 -0
- metadata +61 -0
data/USAGE
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
Description:
|
2
|
+
This functions much like the normal scaffolding, and is based off of its
|
3
|
+
code, but it provides instead a scaffold of a list and show that is
|
4
|
+
visible from the root directory, and a secondary scaffold inside an
|
5
|
+
administrative directory with full action control.
|
6
|
+
|
7
|
+
Example
|
8
|
+
./script/generate administrated_scaffold Account admin
|
9
|
+
|
10
|
+
Creates a scaffold for model Account with an administrated director admin.
|
11
|
+
|
12
|
+
|
@@ -0,0 +1,214 @@
|
|
1
|
+
class ScaffoldingSandbox
|
2
|
+
include ActionView::Helpers::ActiveRecordHelper
|
3
|
+
|
4
|
+
attr_accessor :form_action, :singular_name, :suffix, :model_instance
|
5
|
+
|
6
|
+
def sandbox_binding
|
7
|
+
binding
|
8
|
+
end
|
9
|
+
|
10
|
+
def default_input_block
|
11
|
+
Proc.new { |record, column| "<p><label for=\"#{record}_#{column.name}\">#{column.human_name}</label><br/>\n#{input(record, column.name)}</p>\n" }
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
class AdministratedScaffoldGenerator < Rails::Generator::NamedBase
|
17
|
+
attr_reader :admin_directory,
|
18
|
+
:controller_class_path,
|
19
|
+
:controller_file_path,
|
20
|
+
:controller_class_nesting,
|
21
|
+
:controller_class_nesting_depth,
|
22
|
+
:controller_class_name,
|
23
|
+
:controller_singular_name,
|
24
|
+
:controller_plural_name
|
25
|
+
alias_method :controller_file_name, :controller_singular_name
|
26
|
+
alias_method :controller_table_name, :controller_plural_name
|
27
|
+
|
28
|
+
def initialize(runtime_args, runtime_options = {})
|
29
|
+
super
|
30
|
+
|
31
|
+
# Take controller name from the next argument. Default to the pluralized model name.
|
32
|
+
@admin_directory = args.shift
|
33
|
+
@admin_directory ||= "admin"
|
34
|
+
|
35
|
+
admin_base_name, @admin_class_path, @admin_file_path, @admin_class_nesting, @admin_class_nesting_depth = extract_modules(@admin_directory)
|
36
|
+
@admin_class_name_without_nesting, @admin_singular_name, @admin_plural_name = inflect_names(admin_base_name)
|
37
|
+
|
38
|
+
@controller_name = ActiveRecord::Base.pluralize_table_names ? @name.pluralize : @name
|
39
|
+
|
40
|
+
base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
|
41
|
+
@controller_class_name_without_nesting, @controller_singular_name, @controller_plural_name = inflect_names(base_name)
|
42
|
+
|
43
|
+
if @controller_class_nesting.empty?
|
44
|
+
@controller_class_name = @controller_class_name_without_nesting
|
45
|
+
else
|
46
|
+
@controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def manifest
|
51
|
+
record do |m|
|
52
|
+
# Check for class naming collisions.
|
53
|
+
m.class_collisions controller_class_path, "#{controller_class_name}Controller", "#{controller_class_name}ControllerTest", "#{controller_class_name}Helper"
|
54
|
+
m.class_collisions controller_class_path, "Admin::#{controller_class_name}Controller", "Admin::#{controller_class_name}ControllerTest", "Admin::#{controller_class_name}Helper"
|
55
|
+
|
56
|
+
# Controller, helper, views, and test directories.
|
57
|
+
m.directory File.join('app/controllers', controller_class_path)
|
58
|
+
m.directory File.join('app/controllers', @admin_directory, controller_class_path)
|
59
|
+
m.directory File.join('app/helpers', controller_class_path)
|
60
|
+
m.directory File.join('app/helpers', controller_class_path)
|
61
|
+
m.directory File.join('app/views', controller_class_path, controller_file_name)
|
62
|
+
m.directory File.join('app/views', @admin_directory, controller_class_path, controller_file_name)
|
63
|
+
m.directory File.join('test/functional', controller_class_path)
|
64
|
+
m.directory File.join('test/functional', @admin_directory, controller_class_path)
|
65
|
+
|
66
|
+
# Depend on model generator but skip if the model exists.
|
67
|
+
m.dependency 'model', [singular_name], :collision => :skip, :skip_migration => true
|
68
|
+
|
69
|
+
# Scaffolded forms.
|
70
|
+
m.complex_template "form.rhtml",
|
71
|
+
File.join('app/views',
|
72
|
+
@admin_directory,
|
73
|
+
controller_class_path,
|
74
|
+
controller_file_name,
|
75
|
+
"_form.rhtml"),
|
76
|
+
:insert => 'form_scaffolding.rhtml',
|
77
|
+
:sandbox => lambda { create_sandbox },
|
78
|
+
:begin_mark => 'form',
|
79
|
+
:end_mark => 'eoform',
|
80
|
+
:mark_id => singular_name
|
81
|
+
|
82
|
+
|
83
|
+
# Scaffolded views.
|
84
|
+
scaffold_views.each do |action|
|
85
|
+
m.template "view_#{action}.rhtml",
|
86
|
+
File.join('app/views',
|
87
|
+
@admin_file_path,
|
88
|
+
controller_class_path,
|
89
|
+
controller_file_name,
|
90
|
+
"#{action}.rhtml"),
|
91
|
+
:assigns => { :action => action }
|
92
|
+
end
|
93
|
+
|
94
|
+
public_views.each do |action|
|
95
|
+
m.template "view_#{action}_public.rhtml",
|
96
|
+
File.join('app/views',
|
97
|
+
controller_class_path,
|
98
|
+
controller_file_name,
|
99
|
+
"#{action}.rhtml"),
|
100
|
+
:assigns => { :action => action }
|
101
|
+
end
|
102
|
+
|
103
|
+
# Controller class, functional test, helper, and views.
|
104
|
+
m.template 'controller_admin.rb',
|
105
|
+
File.join('app/controllers',
|
106
|
+
@admin_file_path,
|
107
|
+
controller_class_path,
|
108
|
+
"#{controller_file_name}_controller.rb")
|
109
|
+
|
110
|
+
m.template 'controller.rb',
|
111
|
+
File.join('app/controllers',
|
112
|
+
controller_class_path,
|
113
|
+
"#{controller_file_name}_controller.rb")
|
114
|
+
|
115
|
+
m.template 'helper_admin.rb',
|
116
|
+
File.join('app/helpers',
|
117
|
+
@admin_file_path,
|
118
|
+
controller_class_path,
|
119
|
+
"#{controller_file_name}_helper.rb")
|
120
|
+
|
121
|
+
m.template 'helper.rb',
|
122
|
+
File.join('app/helpers',
|
123
|
+
controller_class_path,
|
124
|
+
"#{controller_file_name}_helper.rb")
|
125
|
+
|
126
|
+
# Layout and stylesheet.
|
127
|
+
m.template 'layout.rhtml', "app/views/layouts/#{controller_file_name}.rhtml"
|
128
|
+
m.template 'style.css', 'public/stylesheets/scaffold.css'
|
129
|
+
|
130
|
+
|
131
|
+
# Unscaffolded views.
|
132
|
+
unscaffolded_actions.each do |action|
|
133
|
+
path = File.join('app/views',
|
134
|
+
@admin_file_path,
|
135
|
+
controller_class_path,
|
136
|
+
controller_file_name,
|
137
|
+
"#{action}.rhtml")
|
138
|
+
m.template "controller:view.rhtml", path,
|
139
|
+
:assigns => { :action => action, :path => path}
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
protected
|
145
|
+
# Override with your own usage banner.
|
146
|
+
def banner
|
147
|
+
"Usage: #{$0} scaffold ModelName [AdminDirectory] [action, ...]"
|
148
|
+
end
|
149
|
+
|
150
|
+
def admin_directory
|
151
|
+
@admin_file_path
|
152
|
+
end
|
153
|
+
|
154
|
+
def admin_scope
|
155
|
+
@admin_singular_name
|
156
|
+
end
|
157
|
+
|
158
|
+
def admin_class
|
159
|
+
@admin_class_name_without_nesting
|
160
|
+
end
|
161
|
+
|
162
|
+
def scaffold_views
|
163
|
+
%w(list show new edit)
|
164
|
+
end
|
165
|
+
|
166
|
+
def public_views
|
167
|
+
%w(list show)
|
168
|
+
end
|
169
|
+
|
170
|
+
def scaffold_actions
|
171
|
+
scaffold_views + %w(index create update destroy)
|
172
|
+
end
|
173
|
+
|
174
|
+
def public_actions
|
175
|
+
scaffold_views + %w(index)
|
176
|
+
end
|
177
|
+
|
178
|
+
def model_name
|
179
|
+
class_name.demodulize
|
180
|
+
end
|
181
|
+
|
182
|
+
def unscaffolded_actions
|
183
|
+
args - scaffold_actions
|
184
|
+
end
|
185
|
+
|
186
|
+
def suffix
|
187
|
+
"_#{singular_name}" if options[:suffix]
|
188
|
+
end
|
189
|
+
|
190
|
+
def create_sandbox
|
191
|
+
sandbox = ScaffoldingSandbox.new
|
192
|
+
sandbox.singular_name = singular_name
|
193
|
+
begin
|
194
|
+
sandbox.model_instance = model_instance
|
195
|
+
sandbox.instance_variable_set("@#{singular_name}", sandbox.model_instance)
|
196
|
+
rescue ActiveRecord::StatementInvalid => e
|
197
|
+
logger.error "Before updating scaffolding from new DB schema, try creating a table for your model (#{class_name})"
|
198
|
+
raise SystemExit
|
199
|
+
end
|
200
|
+
sandbox.suffix = suffix
|
201
|
+
sandbox
|
202
|
+
end
|
203
|
+
|
204
|
+
def model_instance
|
205
|
+
base = class_nesting.split('::').inject(Object) do |base, nested|
|
206
|
+
break base.const_get(nested) if base.const_defined?(nested)
|
207
|
+
base.const_set(nested, Module.new)
|
208
|
+
end
|
209
|
+
unless base.const_defined?(@class_name_without_nesting)
|
210
|
+
base.const_set(@class_name_without_nesting, Class.new(ActiveRecord::Base))
|
211
|
+
end
|
212
|
+
class_name.constantize.new
|
213
|
+
end
|
214
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class <%= controller_class_name %>Controller < ApplicationController
|
2
|
+
<% unless suffix -%>
|
3
|
+
def index
|
4
|
+
list
|
5
|
+
render :action => 'list'
|
6
|
+
end
|
7
|
+
<% end -%>
|
8
|
+
|
9
|
+
def list<%= suffix %>
|
10
|
+
@<%= singular_name %>_pages, @<%= plural_name %> = paginate :<%= plural_name %>, :per_page => 10
|
11
|
+
end
|
12
|
+
|
13
|
+
def show<%= suffix %>
|
14
|
+
@<%= singular_name %> = <%= model_name %>.find(params[:id])
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
class <%= admin_class %>::<%= controller_class_name %>Controller < ApplicationController
|
2
|
+
layout '<%= plural_name %>'
|
3
|
+
<% unless suffix -%>
|
4
|
+
def index
|
5
|
+
list
|
6
|
+
render :action => 'list'
|
7
|
+
end
|
8
|
+
<% end -%>
|
9
|
+
|
10
|
+
<% for action in unscaffolded_actions -%>
|
11
|
+
def <%= action %><%= suffix %>
|
12
|
+
end
|
13
|
+
|
14
|
+
<% end -%>
|
15
|
+
# GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html)
|
16
|
+
verify :method => :post, :only => [ :destroy<%= suffix %>, :create<%= suffix %>, :update<%= suffix %> ],
|
17
|
+
:redirect_to => { :action => :list<%= suffix %> }
|
18
|
+
|
19
|
+
def list<%= suffix %>
|
20
|
+
@<%= singular_name %>_pages, @<%= plural_name %> = paginate :<%= plural_name %>, :per_page => 10
|
21
|
+
end
|
22
|
+
|
23
|
+
def show<%= suffix %>
|
24
|
+
@<%= singular_name %> = <%= model_name %>.find(params[:id])
|
25
|
+
end
|
26
|
+
|
27
|
+
def new<%= suffix %>
|
28
|
+
@<%= singular_name %> = <%= model_name %>.new
|
29
|
+
end
|
30
|
+
|
31
|
+
def create<%= suffix %>
|
32
|
+
@<%= singular_name %> = <%= model_name %>.new(params[:<%= singular_name %>])
|
33
|
+
if @<%= singular_name %>.save
|
34
|
+
flash[:notice] = '<%= model_name %> was successfully created.'
|
35
|
+
redirect_to :action => 'list<%= suffix %>'
|
36
|
+
else
|
37
|
+
render :action => 'new<%= suffix %>'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def edit<%= suffix %>
|
42
|
+
@<%= singular_name %> = <%= model_name %>.find(params[:id])
|
43
|
+
end
|
44
|
+
|
45
|
+
def update
|
46
|
+
@<%= singular_name %> = <%= model_name %>.find(params[:id])
|
47
|
+
if @<%= singular_name %>.update_attributes(params[:<%= singular_name %>])
|
48
|
+
flash[:notice] = '<%= model_name %> was successfully updated.'
|
49
|
+
redirect_to :action => 'show<%= suffix %>', :id => @<%= singular_name %>
|
50
|
+
else
|
51
|
+
render :action => 'edit<%= suffix %>'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def destroy<%= suffix %>
|
56
|
+
<%= model_name %>.find(params[:id]).destroy
|
57
|
+
redirect_to :action => 'list<%= suffix %>'
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= all_input_tags(@model_instance, @singular_name, {}) %>
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require File.dirname(__FILE__) + '<%= "/.." * controller_class_nesting_depth %>/../test_helper'
|
2
|
+
require '<%= controller_file_path %>_controller'
|
3
|
+
|
4
|
+
# Re-raise errors caught by the controller.
|
5
|
+
class <%= controller_class_name %>Controller; def rescue_action(e) raise e end; end
|
6
|
+
|
7
|
+
class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase
|
8
|
+
fixtures :<%= table_name %>
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@controller = <%= controller_class_name %>Controller.new
|
12
|
+
@request = ActionController::TestRequest.new
|
13
|
+
@response = ActionController::TestResponse.new
|
14
|
+
end
|
15
|
+
|
16
|
+
<% for action in unscaffolded_actions -%>
|
17
|
+
def test_<%= action %>
|
18
|
+
get :<%= action %>
|
19
|
+
assert_response :success
|
20
|
+
assert_template '<%= action %>'
|
21
|
+
end
|
22
|
+
|
23
|
+
<% end -%>
|
24
|
+
<% unless suffix -%>
|
25
|
+
def test_index
|
26
|
+
get :index
|
27
|
+
assert_response :success
|
28
|
+
assert_template 'list'
|
29
|
+
end
|
30
|
+
|
31
|
+
<% end -%>
|
32
|
+
def test_list<%= suffix %>
|
33
|
+
get :list<%= suffix %>
|
34
|
+
|
35
|
+
assert_response :success
|
36
|
+
assert_template 'list<%= suffix %>'
|
37
|
+
|
38
|
+
assert_not_nil assigns(:<%= plural_name %>)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_show<%= suffix %>
|
42
|
+
get :show<%= suffix %>, :id => 1
|
43
|
+
|
44
|
+
assert_response :success
|
45
|
+
assert_template 'show'
|
46
|
+
|
47
|
+
assert_not_nil assigns(:<%= singular_name %>)
|
48
|
+
assert assigns(:<%= singular_name %>).valid?
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_new<%= suffix %>
|
52
|
+
get :new<%= suffix %>
|
53
|
+
|
54
|
+
assert_response :success
|
55
|
+
assert_template 'new<%= suffix %>'
|
56
|
+
|
57
|
+
assert_not_nil assigns(:<%= singular_name %>)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_create
|
61
|
+
num_<%= plural_name %> = <%= model_name %>.count
|
62
|
+
|
63
|
+
post :create<%= suffix %>, :<%= singular_name %> => {}
|
64
|
+
|
65
|
+
assert_response :redirect
|
66
|
+
assert_redirected_to :action => 'list<%= suffix %>'
|
67
|
+
|
68
|
+
assert_equal num_<%= plural_name %> + 1, <%= model_name %>.count
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_edit<%= suffix %>
|
72
|
+
get :edit<%= suffix %>, :id => 1
|
73
|
+
|
74
|
+
assert_response :success
|
75
|
+
assert_template 'edit<%= suffix %>'
|
76
|
+
|
77
|
+
assert_not_nil assigns(:<%= singular_name %>)
|
78
|
+
assert assigns(:<%= singular_name %>).valid?
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_update<%= suffix %>
|
82
|
+
post :update<%= suffix %>, :id => 1
|
83
|
+
assert_response :redirect
|
84
|
+
assert_redirected_to :action => 'show<%= suffix %>', :id => 1
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_destroy<%= suffix %>
|
88
|
+
assert_not_nil <%= model_name %>.find(1)
|
89
|
+
|
90
|
+
post :destroy, :id => 1
|
91
|
+
assert_response :redirect
|
92
|
+
assert_redirected_to :action => 'list<%= suffix %>'
|
93
|
+
|
94
|
+
assert_raise(ActiveRecord::RecordNotFound) {
|
95
|
+
<%= model_name %>.find(1)
|
96
|
+
}
|
97
|
+
end
|
98
|
+
end
|
data/templates/helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title><%= controller_class_name %>: <%%= controller.action_name %></title>
|
4
|
+
<%%= stylesheet_link_tag 'scaffold' %>
|
5
|
+
</head>
|
6
|
+
<body>
|
7
|
+
|
8
|
+
<p style="color: green"><%%= flash[:notice] %></p>
|
9
|
+
|
10
|
+
<%%= @content_for_layout %>
|
11
|
+
|
12
|
+
</body>
|
13
|
+
</html>
|
data/templates/style.css
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
body { background-color: #fff; color: #333; }
|
2
|
+
|
3
|
+
body, p, ol, ul, td {
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
5
|
+
font-size: 13px;
|
6
|
+
line-height: 18px;
|
7
|
+
}
|
8
|
+
|
9
|
+
pre {
|
10
|
+
background-color: #eee;
|
11
|
+
padding: 10px;
|
12
|
+
font-size: 11px;
|
13
|
+
}
|
14
|
+
|
15
|
+
a { color: #000; }
|
16
|
+
a:visited { color: #666; }
|
17
|
+
a:hover { color: #fff; background-color:#000; }
|
18
|
+
|
19
|
+
.fieldWithErrors {
|
20
|
+
padding: 2px;
|
21
|
+
background-color: red;
|
22
|
+
display: table;
|
23
|
+
}
|
24
|
+
|
25
|
+
#errorExplanation {
|
26
|
+
width: 400px;
|
27
|
+
border: 2px solid red;
|
28
|
+
padding: 7px;
|
29
|
+
padding-bottom: 12px;
|
30
|
+
margin-bottom: 20px;
|
31
|
+
background-color: #f0f0f0;
|
32
|
+
}
|
33
|
+
|
34
|
+
#errorExplanation h2 {
|
35
|
+
text-align: left;
|
36
|
+
font-weight: bold;
|
37
|
+
padding: 5px 5px 5px 15px;
|
38
|
+
font-size: 12px;
|
39
|
+
margin: -7px;
|
40
|
+
background-color: #c00;
|
41
|
+
color: #fff;
|
42
|
+
}
|
43
|
+
|
44
|
+
#errorExplanation p {
|
45
|
+
color: #333;
|
46
|
+
margin-bottom: 0;
|
47
|
+
padding: 5px;
|
48
|
+
}
|
49
|
+
|
50
|
+
#errorExplanation ul li {
|
51
|
+
font-size: 12px;
|
52
|
+
list-style: square;
|
53
|
+
}
|
54
|
+
|
55
|
+
div.uploadStatus {
|
56
|
+
margin: 5px;
|
57
|
+
}
|
58
|
+
|
59
|
+
div.progressBar {
|
60
|
+
margin: 5px;
|
61
|
+
}
|
62
|
+
|
63
|
+
div.progressBar div.border {
|
64
|
+
background-color: #fff;
|
65
|
+
border: 1px solid grey;
|
66
|
+
width: 100%;
|
67
|
+
}
|
68
|
+
|
69
|
+
div.progressBar div.background {
|
70
|
+
background-color: #333;
|
71
|
+
height: 18px;
|
72
|
+
width: 0%;
|
73
|
+
}
|
74
|
+
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<h1>Editing <%= singular_name %></h1>
|
2
|
+
|
3
|
+
<%%= start_form_tag :action => 'update<%= @suffix %>', :id => @<%= singular_name %> %>
|
4
|
+
<%%= render :partial => 'form' %>
|
5
|
+
<%%= submit_tag 'Edit' %>
|
6
|
+
<%%= end_form_tag %>
|
7
|
+
|
8
|
+
<%%= link_to 'Show', :action => 'show<%= suffix %>', :id => @<%= singular_name %> %> |
|
9
|
+
<%%= link_to 'Back', :action => 'list<%= suffix %>' %>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<h1><%= controller_class_name %> Administration</h1>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<tr>
|
5
|
+
<%% for column in <%= model_name %>.content_columns %>
|
6
|
+
<th><%%= column.human_name %></th>
|
7
|
+
<%% end %>
|
8
|
+
</tr>
|
9
|
+
|
10
|
+
<%% for <%= singular_name %> in @<%= plural_name %> %>
|
11
|
+
<tr>
|
12
|
+
<%% for column in <%= model_name %>.content_columns %>
|
13
|
+
<td><%%=h <%= singular_name %>.send(column.name) %></td>
|
14
|
+
<%% end %>
|
15
|
+
<td><%%= link_to 'Show', :action => 'show<%= suffix %>', :id => <%= singular_name %> %></td>
|
16
|
+
<td><%%= link_to 'Edit', :action => 'edit<%= suffix %>', :id => <%= singular_name %> %></td>
|
17
|
+
<td><%%= link_to 'Destroy', { :action => 'destroy<%= suffix %>', :id => <%= singular_name %> }, :confirm => 'Are you sure?', :post => true %></td>
|
18
|
+
</tr>
|
19
|
+
<%% end %>
|
20
|
+
</table>
|
21
|
+
|
22
|
+
<%%= link_to 'Previous page', { :page => @<%= singular_name %>_pages.current.previous } if @<%= singular_name %>_pages.current.previous %>
|
23
|
+
<%%= link_to 'Next page', { :page => @<%= singular_name %>_pages.current.next } if @<%= singular_name %>_pages.current.next %>
|
24
|
+
|
25
|
+
<br />
|
26
|
+
|
27
|
+
<%%= link_to 'New <%= singular_name %>', :action => 'new<%= suffix %>' %>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<h1>Listing <%= plural_name %></h1>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<tr>
|
5
|
+
<%% for column in <%= model_name %>.content_columns %>
|
6
|
+
<th><%%= column.human_name %></th>
|
7
|
+
<%% end %>
|
8
|
+
</tr>
|
9
|
+
|
10
|
+
<%% for <%= singular_name %> in @<%= plural_name %> %>
|
11
|
+
<tr>
|
12
|
+
<%% for column in <%= model_name %>.content_columns %>
|
13
|
+
<td><%%=h <%= singular_name %>.send(column.name) %></td>
|
14
|
+
<%% end %>
|
15
|
+
<td><%%= link_to 'Show', :action => 'show<%= suffix %>', :id => <%= singular_name %> %></td>
|
16
|
+
<td><%%= link_to 'Edit', :action => 'edit<%= suffix %>', :id => <%= singular_name %> %></td>
|
17
|
+
<td><%%= link_to 'Destroy', { :action => 'destroy<%= suffix %>', :id => <%= singular_name %> }, :confirm => 'Are you sure?', :post => true %></td>
|
18
|
+
</tr>
|
19
|
+
<%% end %>
|
20
|
+
</table>
|
21
|
+
|
22
|
+
<%%= link_to 'Previous page', { :page => @<%= singular_name %>_pages.current.previous } if @<%= singular_name %>_pages.current.previous %>
|
23
|
+
<%%= link_to 'Next page', { :page => @<%= singular_name %>_pages.current.next } if @<%= singular_name %>_pages.current.next %>
|
24
|
+
|
25
|
+
<br />
|
26
|
+
|
27
|
+
<%%= link_to 'Administrate <%= plural_name %>', :controller => '/<%= admin_scope %>/<%= controller_singular_name %>', :action => 'index<%= suffix %>' %>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<%% for column in <%= model_name %>.content_columns %>
|
2
|
+
<p>
|
3
|
+
<b><%%= column.human_name %>:</b> <%%=h @<%= singular_name %>.send(column.name) %>
|
4
|
+
</p>
|
5
|
+
<%% end %>
|
6
|
+
|
7
|
+
<%%= link_to 'Edit', :action => 'edit<%= suffix %>', :id => @<%= singular_name %> %> |
|
8
|
+
<%%= link_to 'Back', :action => 'list<%= suffix %>' %>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<%% for column in <%= model_name %>.content_columns %>
|
2
|
+
<p>
|
3
|
+
<b><%%= column.human_name %>:</b> <%%=h @<%= singular_name %>.send(column.name) %>
|
4
|
+
</p>
|
5
|
+
<%% end %>
|
6
|
+
|
7
|
+
<%%= link_to 'Edit', :action => 'edit<%= suffix %>', :id => @<%= singular_name %> %> |
|
8
|
+
<%%= link_to 'Back', :action => 'list<%= suffix %>' %>
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.8.11
|
3
|
+
specification_version: 1
|
4
|
+
name: administrated_scaffold
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.0.1
|
7
|
+
date: 2006-07-13 00:00:00 -04:00
|
8
|
+
summary: A scaffold generator that creates a public and administrative controller and views.
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: mbleigh@mbleigh.com
|
12
|
+
homepage: http://www.mbleigh.com/software/administrative-scaffold/
|
13
|
+
rubyforge_project:
|
14
|
+
description:
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: false
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
authors:
|
29
|
+
- Michael Bleigh
|
30
|
+
files:
|
31
|
+
- templates/controller.rb
|
32
|
+
- templates/controller_admin.rb
|
33
|
+
- templates/form.rhtml
|
34
|
+
- templates/form_scaffolding.rhtml
|
35
|
+
- templates/functional_test.rb
|
36
|
+
- templates/helper.rb
|
37
|
+
- templates/helper_admin.rb
|
38
|
+
- templates/layout.rhtml
|
39
|
+
- templates/style.css
|
40
|
+
- templates/view_edit.rhtml
|
41
|
+
- templates/view_list.rhtml
|
42
|
+
- templates/view_list_public.rhtml
|
43
|
+
- templates/view_new.rhtml
|
44
|
+
- templates/view_show.rhtml
|
45
|
+
- templates/view_show_public.rhtml
|
46
|
+
- administrated_scaffold_generator.rb
|
47
|
+
- USAGE
|
48
|
+
test_files: []
|
49
|
+
|
50
|
+
rdoc_options: []
|
51
|
+
|
52
|
+
extra_rdoc_files: []
|
53
|
+
|
54
|
+
executables: []
|
55
|
+
|
56
|
+
extensions: []
|
57
|
+
|
58
|
+
requirements: []
|
59
|
+
|
60
|
+
dependencies: []
|
61
|
+
|