Skip to content

Commit fc6c6e3

Browse files
committed
Update routes and version up
1 parent 15a11e0 commit fc6c6e3

12 files changed

+61
-73
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66
/spec/todoapp/log/*.log
77
/spec/todoapp/storage/
88
/spec/todoapp/tmp/
9+
/rdoc/
10+
/db/

README.md

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
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+
```markdown
14
# Todoro
5+
26
A lightweight Rails engine that lets any model manage task lists and tasks with a simple, flexible API.
37

48
![Totoro](totoro.png)
@@ -13,42 +17,75 @@ gem "todoro"
1317

1418
And then execute:
1519

16-
```bash
17-
$ bundle
20+
```sh
21+
$ bundle install
1822
```
1923

2024
Or install it yourself as:
2125

22-
```bash
26+
```sh
2327
$ gem install todoro
2428
```
2529

2630
## Usage
2731

28-
Generate the required migrations
32+
Generate the required migrations:
2933

30-
```ruby
31-
rails generate todoro:install
34+
```sh
35+
$ rails generate todoro:install
36+
$ rails db:migrate
3237
```
3338

34-
Include Taskable in the model(s) that can have tasks
39+
Include `acts_as_taskable` in the model(s) that can have tasks:
3540

3641
```ruby
3742
class Project < ApplicationRecord
3843
acts_as_taskable
3944
end
4045
```
4146

42-
Now, a Project can have task lists and tasks!
47+
Now, a `Project` can have task lists and tasks:
4348

44-
```bash
49+
```ruby
4550
project = Project.create(name: "Website Redesign")
4651
task_list = project.create_task_list("Development Tasks")
4752
task = project.add_task_to_list(task_list, "Build homepage", "Implement UI components")
4853

4954
puts project.tasks # Lists all tasks in all its task lists
5055
```
5156

57+
## Mounting the Engine
58+
59+
To access Todoro's routes, mount the engine in your application's routes file:
60+
61+
```ruby
62+
# config/routes.rb
63+
Rails.application.routes.draw do
64+
mount Todoro::Engine, at: '/todoro'
65+
# Other routes...
66+
end
67+
```
68+
69+
This makes Todoro's features accessible under the `/todoro` path (e.g., `http://yourdomain.com/todoro`).
70+
71+
### Customizing the Mount Path
72+
73+
You can mount Todoro at any path that fits your application's structure:
74+
75+
- To mount at the root:
76+
77+
```ruby
78+
Rails.application.routes.draw do
79+
mount Todoro::Engine, at: '/'
80+
# Other routes...
81+
end
82+
```
83+
84+
Now, Todoro's routes are available at the root URL (e.g., `http://yourdomain.com/`).
85+
5286

5387
## License
54-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
88+
89+
The gem is available as open source under the terms of the [MIT License](MIT-LICENSE).
90+
91+
```

app/controllers/todoro/task_lists_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def new
1616
def create
1717
@task_list = @taskable.task_lists.new(task_list_params)
1818
if @task_list.save
19-
redirect_to taskable_task_lists_path(taskable: @taskable), notice: "Task list created successfully."
19+
redirect_to task_lists_path(taskable: @taskable), notice: "Task list created successfully."
2020
else
2121
render :new
2222
end
@@ -26,7 +26,7 @@ def edit; end
2626

2727
def update
2828
if @task_list.update(task_list_params)
29-
redirect_to taskable_task_lists_path(taskable: @task_list.taskable), notice: "Task list updated successfully."
29+
redirect_to task_lists_path(taskable: @task_list.taskable), notice: "Task list updated successfully."
3030
else
3131
render :edit
3232
end
@@ -35,7 +35,7 @@ def update
3535
def destroy
3636
taskable = @task_list.taskable
3737
@task_list.destroy
38-
redirect_to taskable_task_lists_path(taskable: taskable), notice: "Task list deleted."
38+
redirect_to task_lists_path(taskable: taskable), notice: "Task list deleted."
3939
end
4040

4141
private

app/controllers/todoro/tasks_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def new
1010
def create
1111
@task = @task_list.tasks.new(task_params)
1212
if @task.save
13-
redirect_to todoro.taskable_task_list_path(taskable: @task_list.taskable.class.name, taskable_id: @task_list.taskable.id, id: @task_list.id), notice: "Task created successfully."
13+
redirect_to task_list_path(taskable: @task_list.taskable.class.name, taskable_id: @task_list.taskable.id, id: @task_list.id), notice: "Task created successfully."
1414
else
1515
render :new
1616
end
@@ -33,7 +33,7 @@ def destroy
3333

3434
def complete
3535
@task.update(status: "completed")
36-
redirect_to todoro.taskable_task_list_path(taskable: @task_list.taskable.class.name, taskable_id: @task_list.taskable.id, id: @task_list.id), notice: "Task marked as completed."
36+
redirect_to task_list_path(taskable: @task_list.taskable.class.name, taskable_id: @task_list.taskable.id, id: @task_list.id), notice: "Task marked as completed."
3737
end
3838

3939
private

config/routes.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
Todoro::Engine.routes.draw do
2-
resources :taskables, only: [] do
3-
resources :task_lists do
4-
resources :tasks do
5-
member do
6-
patch :complete
7-
end
2+
resources :task_lists do
3+
resources :tasks do
4+
member do
5+
patch :complete
86
end
97
end
108
end

lib/todoro/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Todoro
2-
VERSION = "0.1.3"
2+
VERSION = "0.1.4"
33
end

spec/todoapp/db/migrate/20250214105918_create_projects.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class CreateProjects < ActiveRecord::Migration[8.0]
1+
class CreateProjects < ActiveRecord::Migration[ActiveRecord::Migration.current_version]
22
def change
33
create_table :projects do |t|
44
t.string :name

spec/todoapp/db/migrate/20250215212253_create_todoro_task_lists.rb

Lines changed: 0 additions & 10 deletions
This file was deleted.

spec/todoapp/db/migrate/20250215212254_create_todoro_tasks.rb

Lines changed: 0 additions & 20 deletions
This file was deleted.

spec/todoapp/db/migrate/20250215212255_create_todoro_reminders.rb

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)