-
-
Notifications
You must be signed in to change notification settings - Fork 120
Closed
Description
One of the confusing things in Chapter 2 is the block inside the namespace :api
Listing 4. config/routes.rb
Rails.application.routes.draw do
namespace :api, defaults: { format: :json } do
namespace :v1 do <= This guy
# We are going to list our resources here
end
end
end
You then commit as "Set the routes constraints for the api". So far no problem. Then we see.
Listing 5. config/routes.rb
Rails.application.routes.draw do
# Api definition
namespace :api, defaults: { format: :json } do
# We are going to list our resources here <= where's it gone?
end
end
This is a bit confusing as the version namespace :v1
has disappeared. Maybe it's because it wasn't interesting? Maybe because it's a mistake? However, In Listing 6 we have namespace changed to scope.
Listing 6. config/routes.rb
Rails.application.routes.draw do
# Api definition
namespace :api, defaults: { format: :json } do
scope module: :v1 do <= so we changed namespace to scope?
# We are going to list our resources here
end
end
end
Is the progression from Listing 4 (adding an inner namespace), Listing 5 (missing it out again) and Listing 6 (inner scope module) deliberate? It's quite confusing to follow and not clear from the text why these changes happened.
Metadata
Metadata
Assignees
Labels
No labels