Skip to content

Latest commit

 

History

History
42 lines (37 loc) · 700 Bytes

rake.md

File metadata and controls

42 lines (37 loc) · 700 Bytes

Rake Tasks

Simple task

Code

desc "Says to you a Hello World"
task :hello_world do
  puts "Hello world"
end

Console call

rake hello_world

Task with arguments

Code

desc "Create a default user as admin"
task :create_user, [:email, :password] do |t, args|
  args.email # => email argument
  args.password # => password argument
end

Console call

rake create_user[[email protected],mypassword]

Tasks with dependencies

task :environment do
  puts "loading environment!"
end
...
desc "This task loads another task"
task :create_user => :environment do
  puts "This task will execute task environment before"
end