Skip to content

Instantly share code, notes, and snippets.

@brpaz
Forked from kinopyo/gist:3444889
Created February 22, 2015 09:55
Show Gist options
  • Save brpaz/9275a853c396ae2d82ef to your computer and use it in GitHub Desktop.
Save brpaz/9275a853c396ae2d82ef to your computer and use it in GitHub Desktop.
Rake task example #rake
# [RAILS_ROOT]/lib/tasks/sample.rake
desc "print hello world!" # description.
task "hello_world" do # rake task name.
p "hello world!" # print "hello world!"
end
namespace :myapp do
desc "import data from somewhere"
# load rails environment
task :import_data => :environment do
end
desc "drop and create db task."
task "drop_and_create" => ["db:drop", "db:create"] do
end
end
### in your console
# show rake task
rake hello_world
rake hello_world
rake myapp:import_data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment