Instead of running each rake task individually like this:
rake db:drop rake db:create rake db:migrate rake db:load
I want to run one rake task that does all for.
This is what I have for my rakefile:
desc 'This rebuilds development db' namespace :rebuild_dev do Rake::Task["db:drop"].execute Rake::Task["db:create"].execute Rake::Task["db:migrate"].execute Rake::Task["db:load"].execute end
The above doesn't work when I run it.
You can get a list of Rake tasks available to you, which will often depend on your current directory, by typing rake --tasks .
Go to Websites & Domains and click Ruby. After gems installation you can try to run a Rake task by clicking Run rake task. In the opened dialog, you can provide some parameters and click OK - this will be equivalent to running the rake utility with the specified parameters in the command line.
Rake is a popular task runner for Ruby and Rails applications. For example, Rails provides the predefined Rake tasks for creating databases, running migrations, and performing tests. You can also create custom tasks to automate specific actions - run code analysis tools, backup databases, and so on.
These are small tasks that without Rake would be scattered all over your project on different files. Rake centralizes access to your tasks. Rake also makes a few things easier, like finding files that match a certain pattern & that have been modified recently.
You can do it with dependencies on a task with no body.
desc 'This rebuilds development db' task :rebuild_dev => ["db:drop", "db:create", "db:migrate", "db:load"]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With