1 class MailerGenerator
< Rails
::Generator::NamedBase
4 # Check for class naming collisions.
5 m
.class_collisions class_name
, "#{class_name}Test"
7 # Mailer, view, test, and fixture directories.
8 m
.directory File
.join('app/models', class_path
)
9 m
.directory File
.join('app/views', file_path
)
10 m
.directory File
.join('test/unit', class_path
)
11 m
.directory File
.join('test/fixtures', file_path
)
13 # Mailer class and unit test.
14 m
.template
"mailer.rb", File
.join('app/models', class_path
, "#{file_name}.rb")
15 m
.template
"unit_test.rb", File
.join('test/unit', class_path
, "#{file_name}_test.rb")
17 # View template and fixture for each action.
18 actions
.each
do |action
|
19 relative_path
= File
.join(file_path
, action
)
20 view_path
= File
.join('app/views', "#{relative_path}.erb")
21 fixture_path
= File
.join('test/fixtures', relative_path
)
23 m
.template
"view.erb", view_path
,
24 :assigns => { :action => action
, :path => view_path
}
25 m
.template
"fixture.erb", fixture_path
,
26 :assigns => { :action => action
, :path => view_path
}