I know you can view all possible rake tasks by typing
rake -T
But I need to know what exactly a task does. From the output, how can I find a source file that actually has the task? For example, I'm trying to find the source for the db:schema:dump task.
I know this is an old question, but in any case:
This was introduced in rake 0.9.0.
http://rake.rubyforge.org/doc/release_notes/rake-0_9_0_rdoc.html
There is no programmatic way to do this unfortunately. Rake tasks can be loaded either from rails itself, lib/tasks, or from any plugin with a tasks directory.
This should nab most everything not within Rails itself:
As for
db:schema:dump
, here's the source:It can be found on line 242 of lib/tasks/database.rake in the rails 2.2.2 gem. If you've got a different version of Rails, just search for "
namespace :schema
".You probably actually want the source of the
ActiveRecord::SchemaDumper
, but I think you should have no trouble figuring out where that is. :-)Despite what others have said, you can programmatically get the source location of rake tasks in a rails application. To do this, just run something like the following in your code or from a console:
This will return the source locations of any code that gets executed for this task. You can also use
#prerequisites
instead of#source_location
to get a list of prerequisite task names (e.g. 'environment', etc).You can also list all tasks loaded using:
UPDATE: See Magne's good answer below. For versions of rake >= 0.9.0 you can use
rake -W
to show the source location of your rake tasks.For most rake tasks in Rails, look in the Rails gem directory, in lib/tasks.
If you've vendored Rails into your app directory structure then look in vendor/rails/railties/lib/tasks instead
Either way, db:schema:dump is in databases.rake.