Common tasks
Short answers to "how do I …?". Each answer is one line and links to the page with the code. The pages assume the app from Getting started.
Some tasks have no complete, copy-and-run example yet. Those rows link the closest page and say "(complete example coming)".
Table of contents
Tasks
| Task | Answer | Read |
|---|---|---|
| Sign up a user | Check the password with passwords::strength_score, hash it with passwords::hash, and store the hash on the user row. | Getting started, Step 14 · Hashing on signup |
| Log in | Check the password with passwords::verify, then start a session or issue a JWT. | Getting started, Step 14 · Verifying on login · Sessions |
| Reset a password | PasswordReset::issue makes a signed link to email; confirm_password_reset_pool checks it and stores the new hash. | Password reset (complete example coming) |
| Upload a file | save_uploads checks the file and writes it to a Storage; you save the returned key on a model. | Upload an avatar, end to end |
| Send an email | Build an Email, pick a mailer, and call email.send(&mailer). | Sending email |
| Run a background job | Implement Job, register it on a queue, start the queue, and dispatch from a handler. | Background jobs |
| Test a view | Wrap your router in TestClient and send requests in process, with no server. | Testing |
| Deploy | Set RUSTANGO_ENV=prod, run migrate and check --deploy, then build with cargo build --release. | Getting started, Step 18 · Auditing before you deploy |
More recipes: the cookbook
The cookbook is a runnable blog app with recipes for models, the ORM, migrations, the admin, REST APIs, multi-tenancy and more. The recipes are backed by tests. For multi-tenancy itself, start with Multi-tenancy.