trestle_generator 1.0.2 → 1.1.0
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.
- data/USAGE +8 -8
- data/templates/controller.rb +16 -18
- data/templates/functional_test.rb +38 -44
- data/templates/routes.rb +9 -4
- data/templates/view_edit.rhtml +2 -2
- data/templates/{view__index_without_id.rhtml → view_list.rhtml} +1 -1
- data/templates/view_new.rhtml +1 -1
- data/templates/{view__index_with_id.rhtml → view_show.rhtml} +1 -1
- data/trestle_generator.rb +33 -33
- metadata +10 -10
data/USAGE
CHANGED
@@ -4,17 +4,17 @@ Description:
|
|
4
4
|
model does not exist, it creates the model as well. The generated code is
|
5
5
|
equivalent to the "scaffold :model" declaration, making it easy to migrate
|
6
6
|
when you wish to customize your controller and views.
|
7
|
-
|
7
|
+
|
8
8
|
The generator takes a model name, an optional controller name, and a
|
9
9
|
list of views as arguments. Trestle actions and views are created
|
10
10
|
automatically. Any views left over generate empty stubs.
|
11
|
-
|
11
|
+
|
12
12
|
The trestle actions are:
|
13
|
-
|
14
|
-
|
13
|
+
list, new, show, edit, destroy
|
14
|
+
|
15
15
|
The trestle views are:
|
16
|
-
|
17
|
-
|
16
|
+
list, new, show, edit
|
17
|
+
|
18
18
|
If a controller name is not given, the plural form of the model name
|
19
19
|
will be used. The model and controller names may be given in CamelCase
|
20
20
|
or under_score and should not be suffixed with 'Model' or 'Controller'.
|
@@ -23,13 +23,13 @@ Description:
|
|
23
23
|
|
24
24
|
Example:
|
25
25
|
./script/generate trestle Account Bank debit credit
|
26
|
-
|
26
|
+
|
27
27
|
This will generate an Account model and BankController with a full test
|
28
28
|
suite and a basic user interface. Now create the accounts table in your
|
29
29
|
database and browse to http://localhost/bank/ -- voila, you're on Rails!
|
30
30
|
|
31
31
|
Modules Example:
|
32
32
|
./script/generate trestle CreditCard 'admin/credit_card' suspend late_fee
|
33
|
-
|
33
|
+
|
34
34
|
This will generate a CreditCard model and CreditCardController controller
|
35
35
|
in the admin module.
|
data/templates/controller.rb
CHANGED
@@ -1,56 +1,54 @@
|
|
1
1
|
class <%= controller_class_name %>Controller < ApplicationController
|
2
|
-
verify :only => [ '
|
2
|
+
verify :only => [ 'show<%= suffix %>', 'edit<%= suffix %>', 'destroy<%= suffix %>' ],
|
3
3
|
:params => :id,
|
4
4
|
:add_flash => { :notice => 'Missing <%= singular_name %> ID.' },
|
5
|
-
:redirect_to => { :action => '<%= suffix
|
6
|
-
|
5
|
+
:redirect_to => { :action => 'list<%= suffix %>' }
|
6
|
+
|
7
7
|
<% for action in nontrestle_actions -%>
|
8
8
|
def <%= action %><%= suffix %>
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
<% end -%>
|
12
12
|
def destroy<%= suffix %>
|
13
13
|
if request.post?
|
14
14
|
<%= model_name %>.find(params[:id]).destroy
|
15
15
|
flash[:notice] = 'The <%= singular_name %> was successfully destroyed.'
|
16
|
-
redirect_to :action => '<%= suffix
|
16
|
+
redirect_to :action => 'list<%= suffix %>'
|
17
17
|
else
|
18
18
|
flash[:notice] = 'Click Destroy to destroy the <%= singular_name %>.'
|
19
19
|
redirect_to :action => 'edit<%= suffix %>', :id => params[:id]
|
20
20
|
end
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def edit<%= suffix %>
|
24
24
|
if request.post?
|
25
25
|
@<%= singular_name %> = <%= model_name %>.find(params[:id])
|
26
26
|
if @<%= singular_name %>.update_attributes(params[:<%= singular_name %>])
|
27
27
|
flash[:notice] = 'The <%= singular_name %> was successfully edited.'
|
28
|
-
redirect_to :action => '<%= suffix
|
28
|
+
redirect_to :action => 'show<%= suffix %>', :id => @<%= singular_name %>
|
29
29
|
end
|
30
30
|
else
|
31
31
|
@<%= singular_name %> = <%= model_name %>.find(params[:id])
|
32
32
|
end
|
33
33
|
end
|
34
|
-
|
35
|
-
def <%= suffix
|
36
|
-
|
37
|
-
@<%= singular_name %> = <%= model_name %>.find(params[:id])
|
38
|
-
render '<%= plural_name %>/_<%= suffix || 'index' %>_with_id'
|
39
|
-
else
|
40
|
-
@<%= singular_name %>_pages, @<%= plural_name %> = paginate(:<%= plural_name %>)
|
41
|
-
render '<%= plural_name %>/_<%= suffix || 'index' %>_without_id'
|
42
|
-
end
|
34
|
+
|
35
|
+
def list<%= suffix %>
|
36
|
+
@<%= singular_name %>_pages, @<%= plural_name %> = paginate(:<%= plural_name %>)
|
43
37
|
end
|
44
|
-
|
38
|
+
|
45
39
|
def new<%= suffix %>
|
46
40
|
if request.post?
|
47
41
|
@<%= singular_name %> = <%= model_name %>.new(params[:<%= singular_name %>])
|
48
42
|
if @<%= singular_name %>.save
|
49
43
|
flash[:notice] = 'A new <%= singular_name %> was successfully added.'
|
50
|
-
redirect_to :action => '<%= suffix
|
44
|
+
redirect_to :action => 'list<%= suffix %>'
|
51
45
|
end
|
52
46
|
else
|
53
47
|
@<%= singular_name %> = <%= model_name %>.new
|
54
48
|
end
|
55
49
|
end
|
50
|
+
|
51
|
+
def show<%= suffix %>
|
52
|
+
@<%= singular_name %> = <%= model_name %>.find(params[:id])
|
53
|
+
end
|
56
54
|
end
|
@@ -6,99 +6,93 @@ class <%= controller_class_name %>Controller; def rescue_action(e) raise e end;
|
|
6
6
|
|
7
7
|
class <%= controller_class_name %>ControllerTest < Test::Unit::TestCase
|
8
8
|
fixtures :<%= table_name %>
|
9
|
-
|
9
|
+
|
10
10
|
def setup
|
11
11
|
@controller = <%= controller_class_name %>Controller.new
|
12
12
|
@request = ActionController::TestRequest.new
|
13
13
|
@response = ActionController::TestResponse.new
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
<% for action in nontrestle_actions -%>
|
17
17
|
def test_<%= action %>
|
18
18
|
get '<%= action %>'
|
19
19
|
assert_response :success
|
20
20
|
assert_template '<%= action %>'
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
<% end -%>
|
24
|
-
def test_<%= suffix || 'index' %>
|
25
|
-
get '<%= suffix || 'index' %>'
|
26
|
-
assert_response :success
|
27
|
-
assert_template '<%= plural_name %>/_<%= suffix || 'index' %>_without_id'
|
28
|
-
end
|
29
|
-
|
30
24
|
def test_destroy<%= suffix %>_using_get
|
31
25
|
assert_not_nil <%= model_name %>.find(1)
|
32
|
-
|
26
|
+
|
33
27
|
get 'destroy<%= suffix %>', :id => 1
|
34
28
|
assert_response :redirect
|
35
29
|
assert_redirected_to :action => 'edit<%= suffix %>'
|
36
|
-
|
30
|
+
|
37
31
|
assert_not_nil <%= model_name %>.find(1)
|
38
32
|
end
|
39
|
-
|
33
|
+
|
40
34
|
def test_destroy<%= suffix %>_using_post
|
41
35
|
assert_not_nil <%= model_name %>.find(1)
|
42
|
-
|
36
|
+
|
43
37
|
post 'destroy<%= suffix %>', :id => 1
|
44
38
|
assert_response :redirect
|
45
|
-
assert_redirected_to :action => '<%= suffix
|
46
|
-
|
39
|
+
assert_redirected_to :action => 'list<%= suffix %>'
|
40
|
+
|
47
41
|
assert_raise(ActiveRecord::RecordNotFound) { <%= model_name %>.find(1) }
|
48
42
|
end
|
49
|
-
|
43
|
+
|
50
44
|
def test_edit<%= suffix %>_using_get
|
51
45
|
get 'edit<%= suffix %>', :id => 1
|
52
|
-
|
46
|
+
|
53
47
|
assert_response :success
|
54
48
|
assert_template 'edit<%= suffix %>'
|
55
|
-
|
49
|
+
|
56
50
|
assert_not_nil assigns(:<%= singular_name %>)
|
57
51
|
assert assigns(:<%= singular_name %>).valid?
|
58
52
|
end
|
59
|
-
|
53
|
+
|
60
54
|
def test_edit<%= suffix %>_using_post
|
61
55
|
post 'edit<%= suffix %>', :id => 1
|
62
56
|
assert_response :redirect
|
63
|
-
assert_redirected_to :action => '<%= suffix
|
57
|
+
assert_redirected_to :action => 'show<%= suffix %>', :id => 1
|
64
58
|
end
|
65
|
-
|
66
|
-
def
|
67
|
-
get '<%= suffix
|
68
|
-
|
59
|
+
|
60
|
+
def test_list<%= suffix %>
|
61
|
+
get 'list<%= suffix %>'
|
62
|
+
|
69
63
|
assert_response :success
|
70
|
-
assert_template '<%= plural_name %>/
|
71
|
-
|
64
|
+
assert_template '<%= plural_name %>/list<%= suffix %>'
|
65
|
+
|
72
66
|
assert_not_nil assigns(:<%= plural_name %>)
|
73
67
|
end
|
74
|
-
|
75
|
-
def test_<%= suffix || 'index' %>_with_id
|
76
|
-
get '<%= suffix || 'index' %>', :id => 1
|
77
|
-
|
78
|
-
assert_response :success
|
79
|
-
assert_template '<%= plural_name %>/_<%= suffix || 'index' %>_with_id'
|
80
|
-
|
81
|
-
assert_not_nil assigns(:<%= singular_name %>)
|
82
|
-
assert assigns(:<%= singular_name %>).valid?
|
83
|
-
end
|
84
|
-
|
68
|
+
|
85
69
|
def test_new<%= suffix %>_using_get
|
86
70
|
get 'new<%= suffix %>'
|
87
|
-
|
71
|
+
|
88
72
|
assert_response :success
|
89
73
|
assert_template 'new<%= suffix %>'
|
90
|
-
|
74
|
+
|
91
75
|
assert_not_nil assigns(:<%= singular_name %>)
|
92
76
|
end
|
93
|
-
|
77
|
+
|
94
78
|
def test_new<%= suffix %>_using_post
|
95
79
|
num_<%= plural_name %> = <%= model_name %>.count
|
96
|
-
|
80
|
+
|
97
81
|
post 'new<%= suffix %>', :<%= singular_name %> => {}
|
98
|
-
|
82
|
+
|
99
83
|
assert_response :redirect
|
100
|
-
assert_redirected_to :action => '<%= suffix
|
101
|
-
|
84
|
+
assert_redirected_to :action => 'list<%= suffix %>'
|
85
|
+
|
102
86
|
assert_equal num_<%= plural_name %> + 1, <%= model_name %>.count
|
103
87
|
end
|
88
|
+
|
89
|
+
def test_show<%= suffix %>
|
90
|
+
get 'show<%= suffix %>', :id => 1
|
91
|
+
|
92
|
+
assert_response :success
|
93
|
+
assert_template '<%= plural_name %>/show<%= suffix %>'
|
94
|
+
|
95
|
+
assert_not_nil assigns(:<%= singular_name %>)
|
96
|
+
assert assigns(:<%= singular_name %>).valid?
|
97
|
+
end
|
104
98
|
end
|
data/templates/routes.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
ActionController::Routing::Routes.draw do |map|
|
2
2
|
# Add your own custom routes here.
|
3
3
|
# The priority is based upon order of creation: first created -> highest priority.
|
4
|
-
|
4
|
+
|
5
5
|
# Here's a sample route:
|
6
6
|
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
|
7
7
|
# Keep in mind you can assign values other than :controller and :action
|
@@ -15,7 +15,12 @@ ActionController::Routing::Routes.draw do |map|
|
|
15
15
|
map.connect ':controller/service.wsdl', :action => 'wsdl'
|
16
16
|
|
17
17
|
# Install the default route as the lowest priority.
|
18
|
-
|
19
|
-
|
20
|
-
map.connect ':controller/:
|
18
|
+
ID_REQUIREMENT = /[\d]+/
|
19
|
+
ACTION_REQUIREMENT = /[A-Za-z]\S*/
|
20
|
+
map.connect ':controller/:action', :action => 'list<%= suffix %>',
|
21
|
+
:requirements => { :action => ACTION_REQUIREMENT }
|
22
|
+
map.connect ':controller/:id', :action => 'show<%= suffix %>',
|
23
|
+
:requirements => { :id => ID_REQUIREMENT }
|
24
|
+
map.connect ':controller/:id/:action', :requirements => { :id => ID_REQUIREMENT,
|
25
|
+
:action => ACTION_REQUIREMENT }
|
21
26
|
end
|
data/templates/view_edit.rhtml
CHANGED
@@ -6,5 +6,5 @@
|
|
6
6
|
<%%= end_form_tag %>
|
7
7
|
<%%= button_to 'Destroy', { :action => 'destroy<%= suffix %>', :id => @<%= singular_name %> }, :confirm => 'Are you sure you want to destroy this <%= singular_name %>?' %>
|
8
8
|
|
9
|
-
<%%= link_to 'Show', :action => '<%= suffix
|
10
|
-
<%%= link_to 'Back to list', :action => '<%= suffix
|
9
|
+
<%%= link_to 'Show', :action => 'show<%= suffix %>', :id => @<%= singular_name %> %> |
|
10
|
+
<%%= link_to 'Back to list', :action => 'list<%= suffix %>' %>
|
@@ -12,7 +12,7 @@
|
|
12
12
|
<%% for column in <%= model_name %>.content_columns %>
|
13
13
|
<td><%%=h <%= singular_name %>.send(column.name) %></td>
|
14
14
|
<%% end %>
|
15
|
-
<td><%%= link_to 'Show', :action => '<%= suffix
|
15
|
+
<td><%%= link_to 'Show', :action => 'show<%= suffix %>', :id => <%= singular_name %> %></td>
|
16
16
|
<td><%%= link_to 'Edit', :action => 'edit<%= suffix %>', :id => <%= singular_name %> %></td>
|
17
17
|
<td><%%= link_to 'Destroy', { :action => 'destroy<%= suffix %>', :id => <%= singular_name %> }, :post => true, :confirm => 'Are you sure you want to destroy this <%= singular_name %>?' %>
|
18
18
|
</tr>
|
data/templates/view_new.rhtml
CHANGED
data/trestle_generator.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
class TrestleSandbox
|
2
2
|
include ActionView::Helpers::ActiveRecordHelper
|
3
|
-
|
3
|
+
|
4
4
|
attr_accessor :form_action, :singular_name, :suffix, :model_instance
|
5
|
-
|
5
|
+
|
6
6
|
def sandbox_binding
|
7
7
|
binding
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
def default_input_block
|
11
11
|
Proc.new { |record, column| "<p><label for=\"#{record}_#{column.name}\">#{column.human_name}</label><br/>\n#{input(record, column.name)}</p>\n" }
|
12
12
|
end
|
@@ -17,15 +17,15 @@ class ActionView::Helpers::InstanceTag
|
|
17
17
|
field_meth = "#{field_type}_field"
|
18
18
|
"<%= #{field_meth} '#{@object_name}', '#{@method_name}' #{options.empty? ? '' : ', '+options.inspect} %>"
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def to_text_area_tag(options = {})
|
22
22
|
"<%= text_area '#{@object_name}', '#{@method_name}' #{options.empty? ? '' : ', '+ options.inspect} %>"
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
def to_date_select_tag(options = {})
|
26
26
|
"<%= date_select '#{@object_name}', '#{@method_name}' #{options.empty? ? '' : ', '+ options.inspect} %>"
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def to_datetime_select_tag(options = {})
|
30
30
|
"<%= datetime_select '#{@object_name}', '#{@method_name}' #{options.empty? ? '' : ', '+ options.inspect} %>"
|
31
31
|
end
|
@@ -45,36 +45,36 @@ class TrestleGenerator < Rails::Generator::NamedBase
|
|
45
45
|
|
46
46
|
def initialize(runtime_args, runtime_options = {})
|
47
47
|
super
|
48
|
-
|
48
|
+
|
49
49
|
# Take controller name from the next argument. Default to the pluralized model name.
|
50
50
|
@controller_name = args.shift
|
51
51
|
@controller_name ||= ActiveRecord::Base.pluralize_table_names ? @name.pluralize : @name
|
52
|
-
|
52
|
+
|
53
53
|
base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
|
54
54
|
@controller_class_name_without_nesting, @controller_singular_name, @controller_plural_name = inflect_names(base_name)
|
55
|
-
|
55
|
+
|
56
56
|
if @controller_class_nesting.empty?
|
57
57
|
@controller_class_name = @controller_class_name_without_nesting
|
58
58
|
else
|
59
59
|
@controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
|
60
60
|
end
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
def manifest
|
64
64
|
record do |m|
|
65
65
|
# Check for class naming collisions.
|
66
66
|
m.class_collisions controller_class_path, "#{controller_class_name}Controller", "#{controller_class_name}ControllerTest", "#{controller_class_name}Helper"
|
67
|
-
|
67
|
+
|
68
68
|
# Controller, helper, views, test, and config directories.
|
69
69
|
m.directory File.join('app/controllers', controller_class_path)
|
70
70
|
m.directory File.join('app/helpers', controller_class_path)
|
71
71
|
m.directory File.join('app/views', controller_class_path, controller_file_name)
|
72
72
|
m.directory File.join('test/functional', controller_class_path)
|
73
73
|
m.directory File.join('config', controller_class_path)
|
74
|
-
|
74
|
+
|
75
75
|
# Depend on model generator but skip if the model exists.
|
76
76
|
m.dependency 'model', [singular_name], :collision => :skip
|
77
|
-
|
77
|
+
|
78
78
|
# Trestle forms.
|
79
79
|
m.complex_template "form.rhtml",
|
80
80
|
File.join('app/views',
|
@@ -86,7 +86,7 @@ class TrestleGenerator < Rails::Generator::NamedBase
|
|
86
86
|
:begin_mark => 'form',
|
87
87
|
:end_mark => 'eoform',
|
88
88
|
:mark_id => singular_name
|
89
|
-
|
89
|
+
|
90
90
|
# Trestle views.
|
91
91
|
trestle_views.each do |action|
|
92
92
|
m.template "view_#{action}.rhtml",
|
@@ -96,28 +96,28 @@ class TrestleGenerator < Rails::Generator::NamedBase
|
|
96
96
|
"#{action}.rhtml"),
|
97
97
|
:assigns => { :action => action }
|
98
98
|
end
|
99
|
-
|
99
|
+
|
100
100
|
# Controller class, functional test, helper, and views.
|
101
101
|
m.template 'controller.rb',
|
102
102
|
File.join('app/controllers',
|
103
103
|
controller_class_path,
|
104
104
|
"#{controller_file_name}_controller.rb")
|
105
|
-
|
105
|
+
|
106
106
|
m.template 'functional_test.rb',
|
107
107
|
File.join('test/functional',
|
108
108
|
controller_class_path,
|
109
109
|
"#{controller_file_name}_controller_test.rb")
|
110
|
-
|
110
|
+
|
111
111
|
m.template 'helper.rb',
|
112
112
|
File.join('app/helpers',
|
113
113
|
controller_class_path,
|
114
114
|
"#{controller_file_name}_helper.rb")
|
115
|
-
|
115
|
+
|
116
116
|
# Layout and stylesheet.
|
117
117
|
m.template 'layout.rhtml', "app/views/layouts/#{controller_file_name}.rhtml"
|
118
118
|
m.template 'style.css', 'public/stylesheets/trestle.css'
|
119
|
-
|
120
|
-
|
119
|
+
|
120
|
+
|
121
121
|
# Non-trestle views.
|
122
122
|
nontrestle_actions.each do |action|
|
123
123
|
path = File.join('app/views',
|
@@ -127,40 +127,40 @@ class TrestleGenerator < Rails::Generator::NamedBase
|
|
127
127
|
m.template "controller:view.rhtml", path,
|
128
128
|
:assigns => { :action => action, :path => path}
|
129
129
|
end
|
130
|
-
|
130
|
+
|
131
131
|
# Routes.
|
132
132
|
m.template 'routes.rb', 'config/routes.rb'
|
133
133
|
end
|
134
134
|
end
|
135
|
-
|
136
|
-
|
135
|
+
|
136
|
+
|
137
137
|
protected
|
138
|
-
|
138
|
+
|
139
139
|
# Override with your own usage banner.
|
140
140
|
def banner
|
141
141
|
"Usage: #{$0} trestle ModelName [ControllerName] [action, ...]"
|
142
142
|
end
|
143
|
-
|
143
|
+
|
144
144
|
def trestle_views
|
145
|
-
%w(edit
|
145
|
+
%w(edit list new show)
|
146
146
|
end
|
147
|
-
|
147
|
+
|
148
148
|
def trestle_actions
|
149
|
-
%w(destroy edit
|
149
|
+
%w(destroy edit list new show)
|
150
150
|
end
|
151
|
-
|
151
|
+
|
152
152
|
def model_name
|
153
153
|
class_name.demodulize
|
154
154
|
end
|
155
|
-
|
155
|
+
|
156
156
|
def nontrestle_actions
|
157
157
|
args - trestle_actions
|
158
158
|
end
|
159
|
-
|
159
|
+
|
160
160
|
def suffix
|
161
161
|
"_#{singular_name}" if options[:suffix]
|
162
162
|
end
|
163
|
-
|
163
|
+
|
164
164
|
def create_sandbox
|
165
165
|
sandbox = TrestleSandbox.new
|
166
166
|
sandbox.singular_name = singular_name
|
@@ -174,7 +174,7 @@ class TrestleGenerator < Rails::Generator::NamedBase
|
|
174
174
|
sandbox.suffix = suffix
|
175
175
|
sandbox
|
176
176
|
end
|
177
|
-
|
177
|
+
|
178
178
|
def model_instance
|
179
179
|
base = class_nesting.split('::').inject(Object) do |base, nested|
|
180
180
|
break base.const_get(nested) if base.const_defined?(nested)
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.10
|
|
3
3
|
specification_version: 1
|
4
4
|
name: trestle_generator
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.0
|
7
|
-
date: 2006-
|
6
|
+
version: 1.1.0
|
7
|
+
date: 2006-03-14
|
8
8
|
summary: "[Rails] A drop-in replacement for the scaffold generator that produces
|
9
9
|
production-ready controllers that are safe from state-changing HTTP GET requests
|
10
10
|
and that have streamlined URLs."
|
@@ -21,11 +21,11 @@ description: "Don
|
|
21
21
|
the HTTP POST method for actions that change data. Well-behaved web applications
|
22
22
|
protect themselves against errant HTTP GET requests such as come from Google Web
|
23
23
|
Accelerator and the like. Scaffolded controllers fail to do this. USABILITY
|
24
|
-
Trestle controllers have just
|
25
|
-
scaffold generator produces controllers that have eight actions. Fewer
|
26
|
-
exposed to the outside world is better if the behavior of these actions
|
27
|
-
line with the semantics of HTTP GET and HTTP POST. The net effect of this
|
28
|
-
improvement is that you will not have to throw away or tweak as much
|
24
|
+
Trestle controllers have just five actions (list, new, show, edit, and destroy).
|
25
|
+
The scaffold generator produces controllers that have eight actions. Fewer
|
26
|
+
actions exposed to the outside world is better if the behavior of these actions
|
27
|
+
is in line with the semantics of HTTP GET and HTTP POST. The net effect of this
|
28
|
+
design improvement is that you will not have to throw away or tweak as much
|
29
29
|
trestle-generated code as you do scaffold-generated code. Less work for you
|
30
30
|
means your application gets built sooner. Tobias L�tke�s postback_generator
|
31
31
|
RubyGem had the same idea, but trestle goes further. A scaffold for a database
|
@@ -42,7 +42,7 @@ description: "Don
|
|
42
42
|
from request parameters /people/99 - GET or POST shows the person record having
|
43
43
|
ID 99 /people/99/edit - GET shows a person form for the person record having ID
|
44
44
|
99 /people/99/edit - POST updates the person record having ID 99 using request
|
45
|
-
parameters
|
45
|
+
parameters /people/99/destroy - GET redirects to /people/99/edit with a notice
|
46
46
|
that the user must click the form�s Destroy button in order to destroy a record
|
47
47
|
/people/99/destroy - POST deletes the person record having ID 99 after prompting
|
48
48
|
the user for confirmation Notice the hierarchical nature of trestle URLs.
|
@@ -79,9 +79,9 @@ files:
|
|
79
79
|
- templates/routes.rb
|
80
80
|
- templates/style.css
|
81
81
|
- templates/view_edit.rhtml
|
82
|
+
- templates/view_list.rhtml
|
82
83
|
- templates/view_new.rhtml
|
83
|
-
- templates/
|
84
|
-
- templates/view__index_with_id.rhtml
|
84
|
+
- templates/view_show.rhtml
|
85
85
|
test_files: []
|
86
86
|
rdoc_options: []
|
87
87
|
extra_rdoc_files: []
|