Sha256: bdf86007849d34ca9bbb64c25a57f069c4a1bf6fe957f06a30916b1b07eaa96a

Contents?: true

Size: 1007 Bytes

Versions: 4

Compression:

Stored size: 1007 Bytes

Contents

desc "Load application environment"
task :environment do
  A9n.root.join("config/environment.rb").tap do |path|
    require path if path.exist?
  end
end

desc "Run application console"
task console: :environment do
  require "irb"
  ARGV.clear
  IRB.start
end

namespace :generate do
  desc "Generate new migration with name given, example: rake generate:migration[CreateUsers]"
  task :migration, [:name] do |name, args|
    klass = args[:name].tr('-', '_').camelize
    number = ActiveRecord::Migration.next_migration_number(0)
    file_name = "#{number}_#{klass.underscore}.rb"
    relative_file_path = File.join("db/migrate", file_name)
    file_path = A9n.root.join(relative_file_path)
    content = <<-CONTENT
      |class #{klass} < ActiveRecord::Migration[#{ActiveRecord::Migration.current_version}]
      |  def change
      |  end
      |end
    CONTENT
    File.open(file_path, "w+") { |f| f.write(content.gsub(/( +\|)/, '')) }
    puts "Created migration file: #{relative_file_path}"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fishplate-7.0.0 lib/fishplate/tasks.rake
fishplate-7.0.0.beta lib/fishplate/tasks.rake
fishplate-1.1.3 lib/fishplate/tasks.rake
fishplate-1.1.2 lib/fishplate/tasks.rake