Skip to content

Commit 5483d16

Browse files
committed
Replace handmade router with rails-routes gem 🎱
1 parent 5be7202 commit 5483d16

File tree

9 files changed

+9
-78
lines changed

9 files changed

+9
-78
lines changed

Diff for: Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ gem 'bootsnap', '>= 1.1.0', require: false
88
gem 'mysql2', '>= 0.3.18', '< 0.5'
99
gem 'puma', '~> 3.11'
1010
gem 'rails', '~> 5.1.5'
11+
gem 'rails-routes'
1112
gem 'tzinfo-data', platforms: %i[mingw mswin x64_mingw jruby]
1213

1314
# === FEATURES ===

Diff for: Gemfile.lock

+3-1
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ GEM
151151
nokogiri (>= 1.6)
152152
rails-html-sanitizer (1.0.4)
153153
loofah (~> 2.2, >= 2.2.2)
154+
rails-routes (0.1.2)
154155
railties (5.1.5)
155156
actionpack (= 5.1.5)
156157
activesupport (= 5.1.5)
@@ -243,6 +244,7 @@ DEPENDENCIES
243244
puma (~> 3.11)
244245
pundit
245246
rails (~> 5.1.5)
247+
rails-routes
246248
rspec-rails (~> 3.6)
247249
rubocop (~> 0.52.1)
248250
shoulda-matchers (~> 3.1)
@@ -256,4 +258,4 @@ RUBY VERSION
256258
ruby 2.5.0p0
257259

258260
BUNDLED WITH
259-
1.16.1
261+
1.17.3

Diff for: config/application.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
require_relative 'boot'
22

3-
require_relative 'router'
4-
53
require 'rails'
64
require 'active_model/railtie'
75
require 'active_job/railtie'

Diff for: config/initializers/router.rb

-7
This file was deleted.

Diff for: config/router.rb

-33
This file was deleted.

Diff for: config/routes.rb

-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,2 @@
11
Rails.application.routes.draw do
2-
scope :v1, module: :v1, defaults: { format: :json } do
3-
specify :articles
4-
end
5-
6-
scope :v2, module: :v2 do
7-
scope :admin, module: :admin do
8-
specify :articles
9-
end
10-
end
11-
12-
specify :articles
132
end

Diff for: config/routes/articles.rb

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
module Routes
2-
module Articles
3-
def call
4-
resources :articles, only: %i[show]
5-
end
6-
end
1+
Rails.application.routes.draw do
2+
resources :articles, only: %i[show]
73
end

Diff for: config/routes/v1/articles.rb

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
module Routes
2-
module V1
3-
module Articles
4-
def call
5-
resources :articles, only: %i[index]
6-
end
7-
end
1+
Rails.application.routes.draw do
2+
scope :v1, module: :v1, defaults: { format: :json } do
3+
resources :articles, only: %i[index]
84
end
95
end

Diff for: config/routes/v2/admin/articles.rb

-11
This file was deleted.

0 commit comments

Comments
 (0)