mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
2594581e9f
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@63 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
22 lines
623 B
Ruby
22 lines
623 B
Ruby
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
|