1 class ControllerGenerator
< Rails
::Generator::NamedBase
4 # Check for class naming collisions.
5 m
.class_collisions
"#{class_name}Controller", "#{class_name}ControllerTest", "#{class_name}Helper"
7 # Controller, helper, views, and test directories.
8 m
.directory File
.join('app/controllers', class_path
)
9 m
.directory File
.join('app/helpers', class_path
)
10 m
.directory File
.join('app/views', class_path
, file_name
)
11 m
.directory File
.join('test/functional', class_path
)
13 # Controller class, functional test, and helper class.
14 m
.template
'controller.rb',
15 File
.join('app/controllers',
17 "#{file_name}_controller.rb")
19 m
.template
'functional_test.rb',
20 File
.join('test/functional',
22 "#{file_name}_controller_test.rb")
24 m
.template
'helper.rb',
25 File
.join('app/helpers',
27 "#{file_name}_helper.rb")
29 # View template for each action.
30 actions
.each
do |action
|
31 path
= File
.join('app/views', class_path
, file_name
, "#{action}.html.erb")
32 m
.template
'view.html.erb', path
,
33 :assigns => { :action => action
, :path => path
}