Kristian
2010-Feb-07 10:03 UTC
[Rails 3] How do I use the new hook functionality to hook up multiple generators for scaffolding etc.
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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.