To get a quick overview of all available tasks, simply run rake or rake -T in your project’s root directory.
General Tasks
These tasks provide general utilities for interacting with your application and managing its codebase.
-
$ rake(orrake default) This command serves as a convenient way to list all available Rake tasks along with their brief descriptions. -
$ rake console(alias:rake c) This task opens anirbconsole, pre-loading your application’s environment. This allows you to directly interact with your models, configurations, and other application components for debugging or quick data manipulation. -
$ rake lintTo maintain code quality and consistency, this task runsstandardrbto check your Ruby code for style and potential quality issues. -
$ rake lint:fixIfstandardrbidentifies any style issues, this task will attempt to automatically fix them, helping you adhere to the project’s coding standards effortlessly. -
$ rake testThis task executes your application’s RSpec test suite. It’s important to note that it sets theRACK_ENVtotestbefore running the tests, ensuring a consistent testing environment.
Database Tasks
These tasks are essential for managing your application’s database schema.
$ rake db:migrateThis command is used to migrate your database schema to its latest version. You also have the flexibility to specify a target version if you need to roll back or forward to a particular database state.- To migrate to the latest version:
rake db:migrateTo migrate to a specific version (e.g., version 123):rake db:migrate[123]
- To migrate to the latest version:
Server Tasks
These tasks help you run your Roda application in different environments.
-
$ rake devThis task starts the Puma web server in development mode on port 4000, making your application accessible for local development. -
$ rake dev:watchFor a more dynamic development experience, this task starts the Puma web server in development mode and utilizesguardto watch for file changes. This setup automatically reloads the application or triggers other development tasks, such as LiveReload, as you make changes to your code. -
$ rake prodWhen you’re ready to deploy, this task starts the Puma web server in production mode on port 4000. It’s crucial to set theDATABASE_URLandSESSION_SECRETenvironment variables before running this task. Additionally, it leverages Ruby’s YJIT for enhanced performance in production.- Usage:
DATABASE_URL="postgres://user:pass@host:port/db" SESSION_SECRET="your_secret_key" rake prod
- Usage:
Asset Compilation Tasks
These tasks are dedicated to managing your frontend assets.
-
$ rake assetsThis command first installs any necessary Node.js dependencies (if they aren’t already present) and then compiles your frontend assets, including JavaScript and CSS, usingesbuild. -
$ rake assets:watchFor continuous frontend development, this task installs Node.js dependencies and then startsesbuildin watch mode. This means your frontend assets will be automatically recompiled whenever changes are detected in your source files.
Generation Tasks
These tasks provide convenient ways to scaffold new components for your application.
$ rake g:migration[migration_name]This task generates a new, empty Sequel migration file within thedb/migrations/directory. The file will be prefixed with a timestamp and named according to themigration_nameyou provide.- Arguments:
migration_name(e.g.,add_posts_table) - A descriptive name for the migration. - Usage:
rake g:migration[add_posts_table]
- Arguments:
$ rake g:routes[branch_name,route1,method:route2,...]This powerful task generates a new Roda hash branch file inapp/routes/, along with corresponding RSpec tests inspec/app/routes/. Optionally, it can also generate view files inapp/views/forGETroutes.- Arguments:
branch_name(e.g.,admin,api/v1): This defines the name of the Roda branch and influences the generated file name and directory structure.route1, method:route2,...: A comma-separated list of routes. Routes can be simple names (which default toGET, e.g.,users) or explicitly specified with an HTTP method (e.g.,posts:post,items:put).
- Usage:
To generate a branch
foowith aGET /foo/barroute:rake g:routes[foo,bar]To generate a branchadminwithGET /admin/usersandPOST /admin/productsroutes:rake g:routes[admin,users,products:post]
- Arguments: