Ruby on Rails
WhatIsRakeAndWhatDoesItDo

What is Rake?

Rake is a Ruby make like utility using standard Ruby syntax for the build specification file.

In english: Rake is a Ruby program that builds other Ruby programs. Rake can handle common programming tasks normally associated with building/compiling software. Rake tasks are defined in a file called rakefile (please feel free to expand/improve this definition — LeeO)

More information about Rake

Rake and Rails

Rake is required by Rails. Rake is used in a variety of ways by Rails, from generating stats and documentation from your codebase to running your tests or clearing your logfiles. Rails comes with a rakefile that automates these tasks.

To list Rakes tasks, enter:


rake --tasks

Which should produce a list containing:

db:fixtures:load Load fixtures into the current environment’s database. Load specific fixtures using FIXTURES=x,y
db:migrate Migrate the database through scripts in db/migrate. Target specific version with VERSION=x
db:schema:dump Create a db/schema.rb file that can be portably used against any DB supported by AR
db:schema:load Load a schema.rb file into the database
db:sessions:clear Clear the sessions table
db:sessions:create Creates a sessions table for use with CGI::Session::ActiveRecordStore
db:structure:dump Dump the database structure to a SQL file
db:test:clone Recreate the test database from the current environment’s database schema
db:test:clone_structure Recreate the test databases from the development structure
db:test:prepare Prepare the test database and load the schema
db:test:purge Empty the test database
doc:app Build the app HTML Files
doc:clobber_app Remove rdoc products
doc:clobber_plugins Remove plugin documentation
doc:clobber_rails Remove rdoc products
doc:plugins Generate documation for all installed plugins
doc:rails Build the rails HTML Files
doc:reapp Force a rebuild of the RDOC files
doc:rerails Force a rebuild of the RDOC files
log:clear Truncates all *.log files in log/ to zero bytes
rails:freeze:edge Lock to latest Edge Rails or a specific revision with REVISION=X (ex: REVISION=4021) or a tag with TAG=Y (ex: TAG=rel_1-1-0)
rails:freeze:gems Lock this application to the current gems (by unpacking them into vendor/rails)
rails:unfreeze Unlock this application from freeze of gems or edge and return to a fluid use of system gems
rails:update Update both configs, scripts and public/javascripts from Rails
rails:update:configs Update boot/config.rb from your current rails install
rails:update:javascripts Update your javascripts from your current rails install
rails:update:scripts Add new scripts to the application script/ directory
stats Report code statistics (KLOCs, etc) from the application
test Test all units and functionals
test:functionals Run tests for functionalsdb:test:prepare
test:integration Run tests for integrationdb:test:prepare
test:plugins Run tests for pluginsenvironment
test:recent Run tests for recentdb:test:prepare
test:uncommitted Run tests for uncommitteddb:test:prepare
test:units Run tests for unitsdb:test:prepare
tmp:cache:clear Clears all files and directories in tmp/cache
tmp:clear Clear session, cache, and socket files from tmp/
tmp:create Creates tmp directories for sessions, cache, and sockets
tmp:sessions:clear Clears all files in tmp/sessions
tmp:sockets:clear Clears all files in tmp/sockets