blob: ae0ad6bbe4deab4d632ff8cd7cc6258b2d8c5941 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
require 'rails_generator'
class MailerGenerator < Rails::Generator::Base
attr_reader :actions
def generate
@actions = args
# Mailer class and unit test.
template "mailer.rb", "app/models/#{file_name}.rb"
template "unit_test.rb", "test/unit/#{file_name}_test.rb"
# Test fixtures directory.
FileUtils.mkdir_p "test/fixtures/#{table_name}"
# View template and fixture for each action.
args.each do |action|
template "view.rhtml", "app/views/#{file_name}/#{action}.rhtml", binding
template "fixture.rhtml", "test/fixtures/#{table_name}/#{action}", binding
end
end
end
|