2012-02-09 4 views
7

모델 생성기가 호출 될 때마다 보석에서 생성기를 실행하고 싶습니다. 레일 : ORM 생성기에 후크

require 'rails' 

module Mygenerator 
    class Railtie < Rails::Railtie 

    config.app_generators.orm :my_generator 

    end 
end 

를 수행하면 제대로 내 발전기를 호출하지만, 레일 '기본 생성기가 더 이상 실행되지 않습니다.

은 내가 invoke를 통해 기본 생성기를 실행할 수 있다고 가정하지만 지나치게 복잡한 것 같다. ORM의 다른 모든 발전기는 어때요?

은 기존에 내 발전기를 "연결"하는 더 좋은 방법이 있나요?


업데이트 :

이 자연스럽게 작동 -하지만 난 아직도 청소기 뭔가를 바라고 있어요 :

module Rails 
    module Generators 
    class ModelGenerator < NamedBase 

     def run_my_custom_generator 
     invoke "my_generator:foo" 
     end 

    end 
    end 
end 

답변

0

방법이

require 'rails' 

class Rails::Generators::ModelGenerator 
    include Mygenerator::full_namespace_here::class 
    extend Mygenerator::full_namespace_here::ClassMethods 
end 
+0

덕분에 같은 약 제안 - 이것이 내 맥락에서 효과가 있는지 알게 될 것입니다. – polarblau

관련 문제