Simple rails rake task refuse to run with error "Don't know how to build task", why?

Rubytastic picture Rubytastic · Oct 15, 2012 · Viewed 45k times · Source

I have this simple rake task which refuses to run. I just don't see why it looks correct. Who can pinpoint me to the probably very simple mistake I made? Thank you!

/lib/tasks/reindex.rb:

namespace :db do

  desc "Tire reindex profiles"

  task :reindex => :environment do
    system "cd #{Rails.root} && rake environment tire:import CLASS='Profile' FORCE=true"
  end

end

The error:

rake db:reindex
rake aborted!
Don't know how to build task 'db:reindex'

Answer

cjc343 picture cjc343 · Oct 15, 2012

Rename your file to reindex.rake and it should work.

Related: How to build task 'db:populate'