Re: Creating a rails 3 app generator executable using thor

Kristian Mandrup
Thu, 28 Jan 2010 22:17:19 -0000

I fixed it with a pretty ugly hack :P

      def initialize(*args, &block)
        super

        @my_options ||= {}
...
          if arg == ''!''
            @my_options[:invert] = true
...
        if @model_attributes.empty?
          @my_options[:skip_model] = true

      def do_skip_model?
        options.skip_model? || @my_options[:skip_model]
      end

      def do_invert?
        options.invert? || @my_options[:invert]
      end


      def create_model
        unless do_skip_model?
...

I''m sure there must be better ways around this!

I have also managed to create executables for all my generators!

http://github.com/kristianmandrup/very_nifty_generators

Enjoy!