开发者

Creating indexes for Mongoid within my application?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜