November 2013
Intermediate to advanced
200 pages
4h 31m
English
With our template handler in hand and rendering multipart emails, the final step is to create a generator for our plug-in. Our generator will hook into Rails’s mailer generator and configure it to create merb instead of erb templates.
Rails generators provide hooks to allow other generators to extend and customize the generated code. A quick look at the mailer generator in the Rails source code reveals the hooks it provides:
| rails/railties/lib/rails/generators/rails/mailer/mailer_generator.rb | |
| | module Rails |
| | module Generators |
| | class MailerGenerator < NamedBase |
| | source_root File.expand_path("../templates", __FILE__) |
| | argument :actions, type: :array, |
| | default: [], banner: "method method" |
| | check_class_collision ... |