Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a rake task by command line in rails

I have defined a rake task as follows in a file called file_locker_task.rake

namespace :myspace do
   task :process => :environment do
      FileLocker.lock_files   
   end
end

How do I execute this rake task from the command line? I tried:

rake myspace:process and rake process but both are throwing an error like this:

rake aborted!
Don't know how to build task 'process'
like image 479
Gayan Kalanamith Avatar asked Oct 09 '13 03:10

Gayan Kalanamith


1 Answers

  1. Run rake -T -A from your Rails home directory to see all the tasks that rake knows about. Yours must be in that list for rake to run it.
  2. By default, in a Rails app, rake looks in the lib/tasks directory and its subdirectories for your .rake files. Check that. (I suspect this is the problem.)
like image 114
Dogweather Avatar answered Nov 16 '22 12:11

Dogweather