Skip to content

Instantly share code, notes, and snippets.

@kinopyo
Created August 24, 2012 02:31
Show Gist options
  • Save kinopyo/3444889 to your computer and use it in GitHub Desktop.
Save kinopyo/3444889 to your computer and use it in GitHub Desktop.
rake task example
# [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
@E2-Meghanadhan
Copy link

need much more clarity..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment