Skip to content

Commit 5ee953b

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

13 files changed

+59
-74
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/

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
todoro (0.1.3)
4+
todoro (0.1.4)
55
rails (~> 7.2.1)
66

77
GEM

README.md

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
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+
13
# Todoro
4+
25
A lightweight Rails engine that lets any model manage task lists and tasks with a simple, flexible API.
36

47
![Totoro](totoro.png)
@@ -13,42 +16,73 @@ gem "todoro"
1316

1417
And then execute:
1518

16-
```bash
17-
$ bundle
19+
```sh
20+
$ bundle install
1821
```
1922

2023
Or install it yourself as:
2124

22-
```bash
25+
```sh
2326
$ gem install todoro
2427
```
2528

2629
## Usage
2730

28-
Generate the required migrations
31+
Generate the required migrations:
2932

30-
```ruby
31-
rails generate todoro:install
33+
```sh
34+
$ rails generate todoro:install
35+
$ rails db:migrate
3236
```
3337

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

3640
```ruby
3741
class Project < ApplicationRecord
3842
acts_as_taskable
3943
end
4044
```
4145

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

44-
```bash
48+
```ruby
4549
project = Project.create(name: "Website Redesign")
4650
task_list = project.create_task_list("Development Tasks")
4751
task = project.add_task_to_list(task_list, "Build homepage", "Implement UI components")
4852

4953
puts project.tasks # Lists all tasks in all its task lists
5054
```
5155

56+
## Mounting the Engine
57+
58+
To access Todoro's routes, mount the engine in your application's routes file:
59+
60+
```ruby
61+
# config/routes.rb
62+
Rails.application.routes.draw do
63+
mount Todoro::Engine, at: '/todoro'
64+
# Other routes...
65+
end
66+
```
67+
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+
5285

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

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.

0 commit comments

Comments
 (0)