How to Use: rake

  1. Add the rake gem to your Gemfile:
gem 'rake'
  1. Install it by running bundle install.

  2. Create a Rakefile containing:

# frozen_string_literal: true

Rake.add_rakelib(File.join('lib', 'tasks'))
  1. Create a hello.rake file in ./lib/tasks containing your code:
# frozen_string_literal: true

# Require your code here:
# require_relative '../../config/environment'

namespace :hello do
  task :world do
    puts 'Hello World!'

  task chain: :world do
    puts 'Chain!'

  task :name, [:who] do |_task, args|
    puts "Hello #{args[:who]}!"
  1. Run it:
bundle exec rake hello:world
# Hello World!

bundle exec rake hello:chain
# Hello World!
# Chain!

bundle exec rake hello:name[Rake]
# Hello Rake!