Mémo Rake

Première publication : 2008-02-18
Tags : rubyrailsrake

Rake est un outil puissant et extensible, distribué avec Rails. Il permet d’automatiser toutes sortes d’actions. En voici un rappel de quelques unes peu citées dans les tutorial commun mais pour autant très utiles :

  • rake db:migrate:redo
    Rollbacks the database one migration and re migrate up. If you want to rollback more than one step, define STEP=x
  • rake db:migrate:reset
    Resets your database using your migrations for the current environment
  • rake db:reset
    Drops and recreates the database from db/schema.rb for the current environment.
  • rake db:rollback
    Rolls the schema back to the previous version. Specify the number of steps with STEP=n
  • rake db:schema:dump
    Create a db/schema.rb file that can be portably used against any DB supported by AR
  • rake db:schema:load
    Load a schema.rb file into the database
  • rake log:clear
    Truncates all *.log files in log/ to zero bytes
  • rake tmp:cache:clear
    Clears all files and directories in tmp/cache
  • rake tmp:clear
    Clear session, cache, and socket files from tmp/
  • rake tmp:create
    Creates tmp directories for sessions, cache, and sockets
  • rake tmp:pids:clear
    Clears all files in tmp/pids
  • rake tmp:sessions:clear
    Clears all files in tmp/sessions
  • rake tmp:sockets:clear
    Clears all files in tmp/sockets
  • rake notes
    Enumerate all annotations
  • rake notes:fixme
    Enumerate all FIXME annotations
  • rake notes:optimize
    Enumerate all OPTIMIZE annotations
  • rake notes:todo
    Enumerate all TODO annotations
  • rake 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)
  • rake rails:freeze:gems
    Lock this application to the current gems (by unpacking them into vendor/rails)
  • rake rails:unfreeze
    Unlock this application from freeze of gems or edge and return to a fluid use of system gems
  • rake rails:update
    Update both configs, scripts and public/javascripts from Rails
  • rake rails:update:configs
    Update config/boot.rb from your current rails install
  • rake rails:update:javascripts
    Update your javascripts from your current rails install
  • rake rails:update:scripts
    Add new scripts to the application script/ directory
  • rake routes
    Print out all defined routes in match order, with names.