I am new in ROR and im using version Ruby 1.9.3 & Rails 3.1.0.
I want to generate rake task. How to generate rake take?
i am using below code for generate rake task in commend prompt.
rails generate task permission my_task1 my_task2
But every time give message "Could not find generator task"
Please help.
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.
You can get a list of Rake tasks available to you, which will often depend on your current directory, by typing rake --tasks . Each task has a description, and should help you find the thing you need.
You create a new file in lib/tasks
like lib/tasks/your_task.rake
.
You add a new task to that file:
namespace :my_app do
desc "a new task to be executed"
task :my_task do
puts "hello rake"
end
end
This would be called like rake my_app:my_task
The task generator was added in Rails 3.2.0
Haven't found the reason for this question why rails generating error. So i have done bit searching somewhere else and found this. May this help. Use this instead -
bundle exec rails g task permission my_task1 my_task2
Rails is not able to find task so this is a work around to get you going.
src - [https://railsguides.net/how-to-generate-rake-task/]
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