APIs on Rails revised in 2017 — Chapter 2

Book from 2014 by Abraham Kuri Vargas, revised in 2017

Chapter 2 - The API

2.2.3 Improving the versioning

I have modified the deprecated methods in lib/spec/api_constraints_spec.rb and included some explanatory comments as I understand them. It looks like this:

ApiConstraints class looks the same as in the book (included for completeness):

routes.rb file looks almost the same as in the book. 
(don’t forget to require ‘api_constraints’ at the top of the file:

The only difference is the beginning before the do … end block. In newer versions of Rails we have:

Rails.application.routes.draw do
# some routes

instead of:

MyApplicationName::application.routes.draw do
# some routes

At the end I have finished chapter 2 with passed tests:

Click here and head to chapter 3