Skip to content

Commit 0670109

Browse files
committed
Update README
1 parent 6f08845 commit 0670109

1 file changed

Lines changed: 38 additions & 27 deletions

File tree

README.md

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,39 @@
1-
# Restomatic
1+
# RESTomatic
22

3-
Better route mappers for Rails applications. Restomatic provides cleaner, more intuitive helpers for defining RESTful routes with proper scoping and namespacing.
3+
RESTomatic helps Rails developers organize nested resources with automatic namespacing. Each nested resource gets its own controller module, making your app cleaner and easier to maintain.
4+
5+
Unlike Rails shallow routes that send everything to one controller, RESTomatic enforces proper separation: `Blogs::PostsController`, `Users::PostsController`, etc. keeping your controllers organized and your codebase more maintainable.
46

57
## Installation
68

79
Add to your Rails application Gemfile:
810

911
```ruby
10-
gem "restomatic"
12+
bundle add "restomatic"
1113
```
14+
That's it! The routing helpers are automatically available in your `config/routes.rb` file.
1215

13-
Then run:
16+
Then start using more RESTful routes in `config/routes.rb`:
1417

15-
```bash
16-
bundle install
17-
```
18+
```ruby
19+
resources :blogs do
20+
nest :posts do # Blogs::PostsController
21+
collection do
22+
get :search # Blogs::PostsController#search
23+
end
24+
end
25+
end
1826

19-
That's it! The routing helpers are automatically available in your `config/routes.rb` file.
27+
resources :posts do
28+
create :comments # Posts::CommentsController#new, #create
29+
end
30+
```
2031

2132
## The Problem
2233

2334
Rails provides shallow routes and nested resources, but the syntax becomes verbose and repetitive, especially when you want to properly namespace controllers.
2435

25-
### Before Restomatic
36+
### Before RESTomatic
2637

2738
```ruby
2839
resources :blogs do
@@ -42,19 +53,19 @@ resources :posts do
4253
end
4354
```
4455

45-
### With Restomatic
56+
### With RESTomatic
4657

4758
```ruby
4859
resources :blogs do
49-
nest :posts do
60+
nest :posts do # Blogs::PostsController
5061
collection do
51-
get :search
62+
get :search # Blogs::PostsController#search
5263
end
5364
end
5465
end
5566

5667
resources :posts do
57-
create :comments
68+
create :comments # Posts::CommentsController#new, #create
5869
end
5970
```
6071

@@ -153,42 +164,42 @@ Rails.application.routes.draw do
153164

154165
# Public blog routes
155166
resources :blogs, only: [:index, :show] do
156-
list :posts
167+
list :posts # Blogs::PostsController#index
157168
end
158169

159170
# Admin area with nested resources
160171
namespace :admin do
161172
resources :blogs do
162-
nest :posts do
163-
create :comments
173+
nest :posts do # Admin::Blogs::PostsController
174+
create :comments # Admin::Blogs::Posts::CommentsController#new, #create
164175
collection do
165-
get :scheduled
166-
post :bulk_publish
176+
get :scheduled # Admin::Blogs::PostsController#scheduled
177+
post :bulk_publish # Admin::Blogs::PostsController#bulk_publish
167178
end
168179
end
169180
end
170181

171182
resources :posts do
172-
edit :seo
173-
show :preview
174-
destroy :featured_image
183+
edit :seo # Admin::Posts::SeosController#edit, #update
184+
show :preview # Admin::Posts::PreviewsController#show
185+
destroy :featured_image # Admin::Posts::FeaturedImagesController#destroy
175186
end
176187
end
177188

178189
# User account management
179190
resource :account do
180191
nest do
181-
edit :profile
182-
edit :password
183-
show :billing
192+
edit :profile # Accounts::ProfilesController#edit, #update
193+
edit :password # Accounts::PasswordsController#edit, #update
194+
show :billing # Accounts::BillingsController#show
184195
end
185196
end
186197
end
187198
```
188199

189200
## How It Works
190201

191-
Restomatic extends `ActionDispatch::Routing::Mapper` to add these helper methods. The helpers automatically:
202+
RESTomatic extends `ActionDispatch::Routing::Mapper` to add these helper methods. The helpers automatically:
192203

193204
1. Detect singular vs. plural resource names
194205
2. Apply appropriate module scoping
@@ -197,7 +208,7 @@ Restomatic extends `ActionDispatch::Routing::Mapper` to add these helper methods
197208

198209
## Philosophy
199210

200-
Rails routing is powerful but can become verbose when building properly organized applications with shallow routes and namespaced controllers. Restomatic embraces Rails conventions while reducing boilerplate, making your routes file more readable and maintainable.
211+
Rails routing is powerful but can become verbose when building properly organized applications with shallow routes and namespaced controllers. RESTomatic embraces Rails conventions while reducing boilerplate, making your routes file more readable and maintainable.
201212

202213
## Requirements
203214

@@ -214,4 +225,4 @@ Rails routing is powerful but can become verbose when building properly organize
214225

215226
## License
216227

217-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
228+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

0 commit comments

Comments
 (0)