Back to Ohmyzsh

Rails

plugins/rails/README.md

latest8.2 KB
Original Source

Rails

This plugin adds completion for Ruby On Rails Framework and Rake commands, as well as some aliases for logs and environment variables.

To use it, add rails to the plugins array in your zshrc file:

zsh
plugins=(... rails)

List of Aliases

Rails aliases

AliasCommandDescription
rcrails consoleInteract with your Rails app from the CLI
rcsrails console --sandboxTest code in a sandbox, without changing any data
rdrails destroyUndo a generate operation
rdbrails dbconsoleInteract with your db from the console
rdcrails db:createCreate the database
rddrails db:dropDelete the database
rdmrails db:migrateRun pending db migrations
rdmdrails db:migrate:downUndo specific db migration
rdmrrails db:migrate:redoRedo specific db migration
rdmsrails db:migrate:statusShow current db migration status
rdmtcrails db:migrate db:test:cloneRun pending migrations and clone db into test database
rdmurails db:migrate:upRun specific db migration
rdrrails db:rollbackRoll back the last migration
rdrsrails db:resetDelete the database and set it up again
rdsrails db:seedSeed the database
rdslrails db:schema:loadLoad the database schema
rdtcrails db:test:cloneClone the database into the test database
rdtprails db:test:prepareDuplicate the db schema into your test database
rgenrails generateGenerate boilerplate code
rgmrails generate migrationGenerate a db migration
rlcrails log:clearClear Rails logs
rmdrails middlewareInteract with Rails middlewares
rnrails notesSearch for notes (FIXME, TODO) in code comments
rprails pluginRun a Rails plugin command
rrrails routesList all defined routes
rrcrails routes --controllerList and filter routes mapped to specific controller
rrerails routes --expandedList all defined routes in expanded table mode
rrgrails routes --grepList and filter the defined routes
rrurails routes --unusedList unused routes
rsrails serverLaunch a web server
rsbrails server --bindLaunch a web server binding it to a specific IP
rsdrails server --debuggerLaunch a web server with debugger
rsprails server --portLaunch a web server and specify the listening port
rstsrails statsPrint code statistics
rtrails testRun Rails tests
rtarails test:allRuns all Rails tests, including system tests
rurails runnerRun Ruby code in the context of Rails

Foreman

AliasCommandDescription
fmnsforeman startInteract with your Rails app from the CLI

Utility aliases

AliasCommandDescription
devlogtail -f log/development.logShow and follow changes to the development log
prodlogtail -f log/production.logShow and follow changes to the production log
testlogtail -f log/test.logShow and follow changes to the test log

Environment settings

AliasCommandDescription
REDRAILS_ENV=developmentSets RAILS_ENV to development
REPRAILS_ENV=productionSets RAILS_ENV to production
RETRAILS_ENV=testSets RAILS_ENV to test

These are global aliases. Use in combination with a command or just run them separately. For example: REP rake db:migrate will migrate the production db.

Legacy

Rake aliases

The following commands are run using rails instead of rake since Rails v5, but are preserved under the prefix rk for backwards compatibility.

AliasCommandDescription
rkdcrake db:createCreate the database
rkddrake db:dropDelete the database
rkdmrake db:migrateRun pending db migrations
rkdmsrake db:migrate:statusShow current db migration status
rkdmtcrake db:migrate db:test:cloneRun pending migrations and clone db into test database
rkdrrake db:rollbackRoll back the last migration
rkdrsrake db:resetDelete the database and set it up again
rkdsrake db:seedSeed the database
rkdslrake db:schema:loadLoad the database schema
rkdtcrake db:test:cloneClone the database into the test database
rkdtprake db:test:prepareDuplicate the db schema into your test database
rklcrake log:clearClear Rails logs
rkmdrake middlewareInteract with Rails middlewares
rknrake notesSearch for notes (FIXME, TODO) in code comments
rkstsrake statsPrint code statistics
rktrake testRun Rails tests

Other

AliasCommand
scruby script/console
sdruby script/destroy
sdruby script/server --debugger
sgruby script/generate
spruby script/plugin
srruby script/runner
sspruby script/spec
sstatthin --stats "/thin/stats" start
  • remote_console <server> <directory>: runs ruby script/console production on a remote server.