Sha256: e0636e16927b749c64a3bf125fe52364bab2a3fb86f97243089c12272d704bbd

Contents?: true

Size: 864 Bytes

Versions: 4

Compression:

Stored size: 864 Bytes

Contents

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

class SocializationGenerator < Rails::Generators::Base
  include Rails::Generators::Migration
  source_root File.expand_path(File.join('..', '..', '..', 'generators', 'socialization', 'templates'), File.dirname(__FILE__))

  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
    copy_file 'model_follow.rb', 'app/models/follow.rb'
    copy_file 'model_like.rb', 'app/models/like.rb'
    migration_template 'migration_follows.rb', 'db/migrate/create_follows.rb'
    sleep 1 # wait a second to have a unique migration timestamp
    migration_template 'migration_likes.rb', 'db/migrate/create_likes.rb'
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
socialization-0.2.2 lib/generators/socialization/socialization_generator.rb
socialization-0.2.1 lib/generators/socialization/socialization_generator.rb
socialization-0.2.0 lib/generators/socialization/socialization_generator.rb
socialization-0.1.0 lib/generators/socialization/socialization_generator.rb