-
-
Save brpaz/9275a853c396ae2d82ef to your computer and use it in GitHub Desktop.
Rake task example #rake
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# [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