Reputation: 15181
I have a foo.rake
file in lib/tasks
directory of a Rails project.
namespace :foo do
desc 'rake task example'
def bar
p "foo bar"
end
end
But the rake
command can't find the task, the following command outputs nothing.
bundle exec rake -T -A | grep foo
How can I run a rake task from command line?
Upvotes: 2
Views: 757
Reputation: 9523
Rake tasks are defined like so:
namespace :foo do
desc 'rake task example'
task :bar do
# Your code here
end
end
Notice task :bar do
instead of a usual method definition style def bar
.
Upvotes: 3