|
1 | | -To enhance the **Todoro** gem's documentation, here's an updated version of the `README.md` file that includes instructions on mounting the engine and customizing the mount path: |
2 | | - |
3 | 1 | # Todoro |
4 | 2 |
|
5 | 3 | A lightweight Rails engine that lets any model manage task lists and tasks with a simple, flexible API. |
@@ -53,35 +51,35 @@ task = project.add_task_to_list(task_list, "Build homepage", "Implement UI compo |
53 | 51 | puts project.tasks # Lists all tasks in all its task lists |
54 | 52 | ``` |
55 | 53 |
|
| 54 | +## Automatic Route Generation |
| 55 | + |
| 56 | +Todoro automatically generates routes for any model that includes `acts_as_taskable`. For example, if `Project` includes `acts_as_taskable`, the following routes are created: |
| 57 | + |
| 58 | +```sh |
| 59 | +GET /projects/:project_id/task_lists(.:format) |
| 60 | +POST /projects/:project_id/task_lists(.:format) |
| 61 | +GET /projects/:project_id/task_lists/:id(.:format) |
| 62 | +PATCH /projects/:project_id/task_lists/:id(.:format) |
| 63 | +DELETE /projects/:project_id/task_lists/:id(.:format) |
| 64 | +GET /projects/:project_id/task_lists/:task_list_id/tasks(.:format) |
| 65 | +POST /projects/:project_id/task_lists/:task_list_id/tasks(.:format) |
| 66 | +``` |
| 67 | + |
| 68 | +These routes are automatically configured, so no additional setup is needed. |
| 69 | + |
56 | 70 | ## Mounting the Engine |
57 | 71 |
|
58 | 72 | To access Todoro's routes, mount the engine in your application's routes file: |
59 | 73 |
|
60 | 74 | ```ruby |
61 | 75 | # config/routes.rb |
62 | 76 | Rails.application.routes.draw do |
63 | | - mount Todoro::Engine, at: '/todoro' |
| 77 | + mount Todoro::Engine, at: "/" |
64 | 78 | # Other routes... |
65 | 79 | end |
66 | 80 | ``` |
67 | 81 |
|
68 | | -This makes Todoro's features accessible under the `/todoro` path (e.g., `http://yourdomain.com/todoro`). |
69 | | - |
70 | | -### Customizing the Mount Path |
71 | | - |
72 | | -You can mount Todoro at any path that fits your application's structure: |
73 | | - |
74 | | -- To mount at the root: |
75 | | - |
76 | | - ```ruby |
77 | | - Rails.application.routes.draw do |
78 | | - mount Todoro::Engine, at: '/' |
79 | | - # Other routes... |
80 | | - end |
81 | | - ``` |
82 | | - |
83 | | - Now, Todoro's routes are available at the root URL (e.g., `http://yourdomain.com/`). |
84 | | - |
| 82 | +Since Todoro dynamically registers routes for `acts_as_taskable` models, no further route configuration is required. |
85 | 83 |
|
86 | 84 | ## License |
87 | 85 |
|
|
0 commit comments