title: Creating an install generator for a Ruby gem
body: <p>I'm pretty new to building Ruby gems and am taking a stab at my first one. I'm in the middle of writing a generator for my gem that will generate a migration in my Rails app. I'm looking to simply include the gem in the Rails application, run "rails g mygem:install" to have it create the migrations, then run "rake db:migrate" to finalize everything. </p>
  
  <p>I've found several different ways to accomplish similar tasks, but so far nothing has worked. I cannot seem to get the Rails application to find the generator. The latest guide I've tried is located here: <a href="http://www.railsdispatch.com/posts/how-rails-3-enables-more-choices-part-1" rel="noreferrer">http://www.railsdispatch.com/posts/how-rails-3-enables-more-choices-part-1</a>.</p>
  
  <p>Here is what my current gem structure looks like:</p>
  
  <pre><code>-lib/
    -generators/
      -templates/
        -some_migration.rb
      -install_generator.rb
    -gemname/
      -rails/
        -railtie.rb
        -engine.rb
        -tasks/
          -gemname.rake
    -gemname.rb
   -spec/
   -gemname.gemspec
  </code></pre>
  
  <p>Here is what my install_generator.rb file looks like:</p>
  
  <pre><code>require 'rails'
  
  module Gemname
    class InstallGenerator &lt; ::Rails::Generators::Base
      include Rails::Generators::Migration
      source_root File.expand_path('../templates', __FILE__)
  
      desc "add the migrations"
      def self.next_migration_number(path)
        unless @prev_migration_nr
          @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
        else
          @prev_migration_nr += 1
        end
       @prev_migration_nr.to_s
      end
  
      def copy_migrations
       migration_template "some_migration.rb", "db/migrate/some_migration.rb"
      end
    end
  end
  </code></pre>
  
  <p>I'm not sure if there's something I'm missing. I'm testing with a Rails 3.2 application that has my gem listed in its Gemfile and the gem is installed. Is there anything wrong with gem folder structure that might be preventing my generator from showing up? Do I need to require something somewhere?</p>
  
  <p>Any help is appreciated.</p>