Sha256: 351571270e4b0835b937ea977c24998afd353a57950e0d938e805b8a5901474e

Contents?: true

Size: 784 Bytes

Versions: 1

Compression:

Stored size: 784 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

    def show_readme
        readme 'README.md'
    end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
acts_as_favoritor-1.1.0 lib/generators/acts_as_favoritor_generator.rb