开发者

Creating indexes for Mongoid within my application?

开发者 https://www.devze.com 2023-03-19 14:46 出处:网络
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

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
0

精彩评论

暂无评论...
验证码 换一张
取 消