If I want to look up the available Rake command syntax, where do I go to
find it?
For example, if I want to look up the syntax of a Rails command I can
find it at:
http://api.rubyonrails.com
I can even look up the core Rake api at:
http://rake.rubyforge.org/
What I can’t find is documentation of indivdual core Rails Rake tasks.
You can read the source of the core rake tasks by doing the following:
a) locate the gem directory for your ruby implementation
b) navigate into the rails-2../lib/tasks
Note: The file that you’re looking for end in the .rake extension.
For example, I’ve been trying to find out if there is a better way for
me to use the rake db:migration task. I’ve always used
rake environment RAILS_ENV=production db:migrate
You can write the above as
rake db:migrate RAILS_ENV=production
Also, you can add a task to your Rails Rakefile and simplify it by doing something
like this
rake db:migrate:production
Next, I would recommend reading code because the API may not provide
the complete picture at this time. Also, there are so many examples of how
to create a rake task and here’s a tutorial here:
http://railscasts.com/episodes/66-custom-rake-tasks
to migrate my production database and that always seems verbose to me.
However, as I can’t find an api or other document (or even where the
code that is run when you run the db:migration task), I have to rely on
google searches to see what other people are using.
Can someone please point me in the right direction.
Next, Rake is simply a gem that is used by Rails. Thus, you can find
the documentation for Rake here and it took a simple Google search:
http://rake.rubyforge.org
If you search for it, you’ll find it.
Good look,
-Conrad