# \[Rails 3\] How do I use the new hook functionality to hook up multiple generators for scaffolding et

**URL:** <https://www.ruby-forum.com/t/rails-3-how-do-i-use-the-new-hook-functionality-to-hook-up-multiple-generators-for-scaffolding-et/183061>\
**Category:** Rails\
**Created:** [February 7, 2010, 11:04am UTC](https://www.ruby-forum.com/t/rails-3-how-do-i-use-the-new-hook-functionality-to-hook-up-multiple-generators-for-scaffolding-et/183061 "2010-02-07T11:04:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kristian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e8c25b/32.png) [@Kristian](https://www.ruby-forum.com/u/Kristian)\
**Post date:** [February 7, 2010, 11:04am UTC](https://www.ruby-forum.com/t/rails-3-how-do-i-use-the-new-hook-functionality-to-hook-up-multiple-generators-for-scaffolding-et/183061/1 "2010-02-07T11:04:48Z")

</div>

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  
other generators.  
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?

## application.rb

Config… do |config|  
config.orm :mongo\_db  
config.form :formtastic  
end

class MyGenerator \< Rails::Generators::Base  
…

hook\_for :formtastic  
hook\_for :model  
end

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  
they used?  
There is also rules for how the hooks are resolved…

Thanks for any info 😉

Kristian
