1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/railties/generators/mailer/mailer_generator.rb

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