Sha256: 77c1534050556bfe18d4830eb06b83ea2d29a777b36d423e559dd57713e14c2b

Contents?: true

Size: 728 Bytes

Versions: 2

Compression:

Stored size: 728 Bytes

Contents

require 'rails/generators'
require 'rails/generators/migration'

class ActsAsFavoritorGenerator < Rails::Generators::Base

    include Rails::Generators::Migration

    def self.source_root
        @source_root ||= File.join File.dirname(__FILE__), 'templates'
    end

    def self.next_migration_number dirname
        if ActiveRecord::Base.timestamped_migrations
            Time.now.utc.strftime '%Y%m%d%H%M%S'
        else
            "%.3d" % (current_migration_number(dirname) + 1)
        end
    end

    def create_migration_file
        migration_template 'migration.rb.erb', 'db/migrate/acts_as_favoritor_migration.rb'
    end

    def create_model
        template 'model.rb', 'app/models/favorite.rb'
    end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
acts_as_favoritor-1.0.2 lib/generators/acts_as_favoritor_generator.rb
acts_as_favoritor-1.0.1 lib/generators/acts_as_favoritor_generator.rb