Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In general, your solution should work:</p> <pre><code>require 'rake' task :environment do puts 'task environment' end namespace :robots do task :update_robots do puts "task robots:update_robots" end end task cron: :environment do puts 'task cron' Rake::Task['robots:update_robots'].reenable Rake::Task['robots:update_robots'].invoke end Rake::Task['robots:update_robots'].invoke Rake::Task[:cron].invoke # &gt;&gt; robots:update_robots was invoked # &gt;&gt; task robots:update_robots # &gt;&gt; task environment # &gt;&gt; task cron # &gt;&gt; task robots:update_robots </code></pre> <p>My first thought is that you must have the rake task wrong (are you <em>sure</em> it's "robots:update_robots" ?)</p> <p>It's unusual to me that you need to reenable it, this implies that what you want is not Rake, but just plain old Ruby. Move the contents of the update_robots task out to a method which you can then invoke directly instead of trying to treat tasks like methods (tasks are for handling dependencies, they only invoke once on purpose, and your need to bend them around that implies you're using the wrong tool for the job). Then, both your code and the robots:update_robots can just call the same method:</p> <pre><code>require 'rake' def update_robots puts "method update_robots" end task :environment do puts 'task environment' end namespace :robots do task :update_robots do update_robots puts "task robots:update_robots" end end task cron: :environment do puts 'task cron' update_robots end Rake::Task['robots:update_robots'].invoke Rake::Task[:cron].invoke # &gt;&gt; method update_robots # &gt;&gt; task robots:update_robots # &gt;&gt; task environment # &gt;&gt; task cron # &gt;&gt; method update_robots </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload