So I have a rake task that runs regularly and afterwards I need to create my indexes again, is there a way I can call those methods directly in ruby without resorting to sending them to the system to execute like this:
task :mytask => :environment do
# do stuff...
`bundle exec rake db:mongoid:create_indexes`
e开发者_开发问答nd
You can make direct calls to other rake tasks in your application with Rake::Task
. So your above code could become:
task :mytask => :environment do
# do stuff...
Rake::Task['db:mongoid:create_indexes']
end
精彩评论