How to get generators call other generators in rails 3

前端 未结 4 861
攒了一身酷
攒了一身酷 2021-02-05 16:58

I am experimenting with gem development, right now specifically generators. So far I have successfully created two generators that do their job just perfectly. These two generat

4条回答
  •  不要未来只要你来
    2021-02-05 17:04

    In your generator, you can just call

    generate "some:generator" # can be anything listed by 'rails g'
    

    for example:

    module MyGem
      class InstallGenerator < Rails::Generators::Base
    
        def run_other_generators
          generate "jquery:install" # or whatever you want here
        end
    
      end
    end
    

    By the way, if you are working on Rails 3 gems, this question can also help out:

    Rails 3 generators in gem

提交回复
热议问题