I have ported a few Rails 2 generators in the past week and have
learned a lot doing it, but I still don’t understand how to take
advantage of the new ‘hook’ functionality, which should make it easy
to hook up multiple generators and have one generator calling multiple
Anyone has any idea how this works from a generator perspective and
how to extend and customize it.
I know there are some trivial examples in the official Rails guide.
Do you simply have to specify the hooks in the application.rb in the
config section and then add hooks in the
generators matching these names?
Config… do |config|
class MyGenerator < Rails::Generators::Base
This all seems very magical and too transparent to work with without
some more understanding of what goes on underneath and how it all
connects. There are also the :in and :as options for hook_for. How are
There is also rules for how the hooks are resolved…
Thanks for any info