blob: b3190918bd16a314cb37769dbd575d436da75bc8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
class <%= controller_class_name %>Controller < ApplicationController
<% unless suffix -%>
def index
list
render_action 'list'
end
<% end -%>
<% for action in unscaffolded_actions -%>
def <%= action %><%= suffix %>
end
<% end -%>
def list<%= suffix %>
@<%= plural_name %> = <%= model_name %>.find_all
end
def show<%= suffix %>
@<%= singular_name %> = <%= model_name %>.find(@params[:id])
end
def new<%= suffix %>
@<%= singular_name %> = <%= model_name %>.new
end
def create<%= suffix %>
@<%= singular_name %> = <%= model_name %>.new(@params[:<%= singular_name %>])
if @<%= singular_name %>.save
flash['notice'] = '<%= model_name %> was successfully created.'
redirect_to :action => 'list<%= suffix %>'
else
render_action 'new<%= suffix %>'
end
end
def edit<%= suffix %>
@<%= singular_name %> = <%= model_name %>.find(@params[:id])
end
def update
@<%= singular_name %> = <%= model_name %>.find(@params[:id])
if @<%= singular_name %>.update_attributes(@params[:<%= singular_name %>])
flash['notice'] = '<%= model_name %> was successfully updated.'
redirect_to :action => 'show<%= suffix %>', :id => @<%= singular_name %>
else
render_action 'edit<%= suffix %>'
end
end
def destroy<%= suffix %>
<%= model_name %>.find(@params[:id]).destroy
redirect_to :action => 'list<%= suffix %>'
end
end
|