Rateaux

This is a collection of useful Rake tasks for Ruby on Rails applications.

Photo of an old wooden Rake on top of hay

Hay Rake photo by Larry Lamb

Install

Add these lines to your app's Gemfile:

# Rake tasks for Rails
gem "rateaux"

Then call bundle install.

Tasks

DB Truncate

Delete all data from the current database.

$ rake db:truncate

DB Drop tables

Delete all data and tables from the current database. This is similar to db:drop but it does not drop the database itself.

$ rake db:drop_tables

DB Migrate Delete Orphaned

When your migration errors with "No migration with version number" you can call this to delete all migrations that don’t have associated files anymore.

$ rake db:migrate:delete_orphaned

DB schema view

View the database structure as an ascii table.

$ rake db:schema:view

DB schema print dump

Print the database structure as a Ruby file. Like db:schema:dump but printed out instead of written to db/schema.rb.

$ rake db:schema:print_dump

I18n word count

Show the number of translated words in every available locale.

$ rake i18n:word_count

Checkout

Remove Rails migrations then checkout a git branch.

$ rake checkout new_branch_name

This will:

  1. Roll back any migrations on your current branch which do not exist on the other branch
  2. Discard any changes to the db/schema.rb file
  3. Check out the other branch
  4. Run any new migrations existing in the other branch
  5. Update your test database

Cache clear

Empty the Rails cache store.

$ rake cache:clear

Sidekiq flush

Empty Sidekiq’s queues.

$ rake sidekiq:flush

Assets Copy Non Digested

Copy assets files with a digest (for example application-d45e…565.css) to their non-digested form (for example application.css).

$ rake assets:copy_non_digested

Frozen string literal

Add the # frozen_string_literal: true header to all Ruby files in the project.

$ rake add_frozen_string_literal_headers

Release

To release a new version, update CHANGELOG.md, update the version in lib/rateaux/version.rb.

Then:

git add CHANGELOG.md lib/rateaux/version.rb
git commit -m v`ruby -r./lib/rateaux/version <<< 'puts Rateaux::VERSION'`
bin/rake release

License

The gem is available as open source under the terms of the MIT License.

The name

In French rateaux means rakes. 🌾