Posted By

jlaplante on 04/22/10


Tagged

rake tasks


Versions (?)

Rake Tasks 2


 / Published in: Ruby
 

URL: http://handyrailstips.com/tips/11-some-handy-rake-tasks

  1. Here are some handy rake tasks you may not be aware of and a quick description of what they do:
  2. Database tasks
  3.  
  4. rake db:create � Will create a database to the settings defined in database.yml for the current environment.
  5.  
  6. rake db:create:all � Will create all of the databases defined in database.yml
  7.  
  8. rake db:drop � Will drop the database for the current environment.
  9.  
  10. rake db:drop:all � Will drop all of the databases defined in database.yml.
  11.  
  12. rake db:migrate:redo � Rolls back one migration and then re-runs the migration again (handy if you wan�t to make a quick change to the last migration).
  13.  
  14. rake db:migrate:reset � Drops all tables from the database and then rebuilds them using your migrations. This will delete all the entries from your current environment�s database.
  15.  
  16. rake db:reset � Drops all tables from the current environment�s database and then rebuilds them using schema.rb.
  17.  
  18. rake db:rollback � Rolls the database schema back to the previous version.
  19.  
  20. rake db:sessions:clear � Clears the sessions table if you�re using ActiveRecord::SessionStore
  21.  
  22. rake db:structure:dump � Dumps the current database structure to a .sql file into app/db/ (really handy for rebuilding your database elsewhere).
  23.  
  24. rake db:test:load � Recreates the test database from the current schema.rb
  25. RDoc tasks
  26.  
  27. rake doc:app � Builds RDoc html files for your entire app in myapp/doc
  28.  
  29. rake doc:clobber_app � Removes the myapp/doc directory and all of its contents.
  30. Gem tasks
  31.  
  32. rake gems � Lists all of the gems your app depends on (both the gems you have specified and their dependencies). The key here is simple: R = Rails framework gems, I = gems installed on the system and F = gems frozen in vendor/gems.
  33.  
  34. rake gems:install � Installs any gems your app requires that are not currently installed on the system
  35.  
  36. rake gems:unpack:dependencies � Unpacks all of the gems your app requires and their dependencies to your vendor/ folder. See tip #9 for more info.
  37. Annotation tasks
  38. (read this tip for more info on annotations)
  39.  
  40. rake notes � Lists all of your annotations
  41.  
  42. rake notes:todo � Lists all of your TODO annotations
  43.  
  44. rake notes:fixme � Lists all of your FIXME annotations
  45.  
  46. rake notes:optimize � Lists all of your OPTIMIZE annotations
  47.  
  48. rake notes:custom � Lists all of your custom annotations. You need to include the ANNOTATION variable with the name of your custom note type.
  49. Rails tasks
  50.  
  51. rake rails:freeze:edge � Freeze to the latest version of rails
  52.  
  53. rake rails:freeze:gems � Freeze to the currently installed version of rails
  54. Miscellaneous tasks
  55.  
  56. rake log:clear � Clears all of the .log files. Handy when your development log starts to get too large. See tip # 2 for keeping your production log under control.
  57.  
  58. rake routes � Displays all of the routes defined in config/routes.rb
  59.  
  60. rake stats � Shows a bunch of useful stats for your app including code-to-test ratio
  61.  
  62. rake tmp:cache:clear � Clears all of the files and directories in tmp/cache
  63.  
  64. That�s just a selection of the rake tasks available. To see the full list run rake -T

Report this snippet  

You need to login to post a comment.